Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
JsonSchema
n/a
0 / 0
n/a
0 / 0
0
n/a
0 / 0
1<?php
2
3namespace MediaWiki\Extension\CommunityConfiguration\Schema;
4
5/**
6 * @note This is only a class to let extending classes override (some) constants defined within
7 * this class.
8 */
9abstract class JsonSchema {
10
11    /**
12     * @var string Default schema standard
13     *
14     * JsonSchemaBuilder supports overriding this, but it might not support future versions of
15     * JSONSchema.
16     */
17    public const JSON_SCHEMA_VERSION = 'https://json-schema.org/draft-04/schema#';
18
19    /**
20     * @var string|null Version of the schema (or null if versions are not used)
21     * @stable to override
22     *
23     * This is included in the $id field of the schema. Feel free to override in implementations.
24     */
25    public const VERSION = null;
26
27    /**
28     * @var string|null Classname of a ISchemaConverter
29     * @stable to override
30     *
31     * @see ISchemaConverter
32     */
33    public const SCHEMA_CONVERTER = null;
34
35    /**
36     * @var string|null A version of the next schema version (or null, when not
37     * available/supported).
38     * @stable to override
39     *
40     * Versions need to be comparable via PHP's version_compare.
41     */
42    public const SCHEMA_NEXT_VERSION = null;
43
44    /**
45     * @var string|null A version of the previous schema version (or null, when not
46     * available/supported).
47     * @stable to override
48     *
49     * Versions need to be comparable via PHP's version_compare.
50     */
51    public const SCHEMA_PREVIOUS_VERSION = null;
52
53    /*
54     * JSON-schema draft-04 supported vocabulary
55     */
56    public const PROPERTIES = 'properties';
57    public const TYPE = 'type';
58    public const ADDITIONAL_PROPERTIES = 'additionalProperties';
59    public const REF = '$ref';
60    public const DEFS = '$defs';
61    public const ITEMS = 'items';
62    public const ENUM = 'enum';
63    // Validation vocabulary
64    public const REQUIRED = 'required';
65    // integer and number types
66    public const MINIMUM = 'minimum';
67    public const MAXIMUM = 'maximum';
68    // string type
69    public const MIN_LENGTH = 'minLength';
70    public const MAX_LENGTH = 'maxLength';
71    public const FORMAT = 'format';
72    public const PATTERN = 'pattern';
73    // array type
74    public const MIN_ITEMS = 'minItems';
75    public const MAX_ITEMS = 'maxItems';
76
77    /**
78     * @var string To define a default value for the property
79     *
80     * Only supported on the root-level. Defaults for objects need to be defined at their root
81     * level.
82     */
83    public const DEFAULT = 'default';
84
85    public const DYNAMIC_DEFAULT = 'dynamicDefault';
86
87    public const TYPE_OBJECT = 'object';
88    public const TYPE_ARRAY = 'array';
89    public const TYPE_STRING = 'string';
90    public const TYPE_INTEGER = 'integer';
91    public const TYPE_NUMBER = 'number';
92    public const TYPE_BOOLEAN = 'boolean';
93
94    /**
95     * Non-standard vocabulary.
96     */
97    public const CONTROL = 'control';
98}