3
3
** JSON X-Type** is a data type format for describing JSON-like structures in a simple and natural way.
4
4
Any [ valid JSON] ( https://www.json.org/ ) can be validated against a ** JSON X-Type** definition.
5
5
6
+ The ** JSON X-Type** could be described by itself ([ 🔗] ( ./x-types.yaml ) ).
7
+
6
8
## Reserved Keywords
7
9
8
- | Keyword | Description | Usage |
9
- | -------------------------------- | ------------------------------------------------------------------- | ---------- |
10
- | string | String type. | key, value |
11
- | number | Number type. | value |
12
- | boolean | Boolean type. | value |
13
- | ` null ` | The ` null ` value. (Note: The string "null" has no special meaning.) | value |
14
- | undefined | Indicates that the value is not set. | value |
15
- | array | Array generic. | key |
16
- | any | Any value (not validated). | value |
17
- | $and ([ 🔗] ( #types-combining ) ) | Represents the combination of array members. | key |
18
- | $ref ([ 🔗] ( #references ) ) | Reference to another ** JSON X-Type** . | key |
19
- | $schema ([ 🔗] ( #literal-schemas ) ) | A literal JSON Schema definition. | key |
10
+ | Keyword | Description | Usage |
11
+ | ----------------------------- | ------------------------------------------------------------------- | ---------- |
12
+ | string | String type. | key, value |
13
+ | number | Number type. | value |
14
+ | boolean | Boolean type. | value |
15
+ | ` null ` | The ` null ` value. (Note: The string "null" has no special meaning.) | value |
16
+ | undefined | Indicates that the value is not set. | value |
17
+ | array | Array generic. | key |
18
+ | any | Any value (not validated). | value |
19
+ | $and ([ 🔗] ( #types-combining ) ) | Represents the combination of array members. | key |
20
+ | $ref ([ 🔗] ( #references ) ) | Reference to another ** JSON X-Type** . | key |
20
21
21
22
The list can be extended with other ` $ ` -prefixed keywords.
22
23
So it's a good idea to escape any custom keys that start with ` $ ` using the ` $literal ` prefix ([ 🔗] ( #literals-escaping ) ).
@@ -103,8 +104,6 @@ Note that it doesn't make sense to combine primitive types or objects that have
103
104
104
105
The above example results in ` foo ` being both ` string ` and ` number ` , which is effectively equivalent to TypeScript's ` never ` type.
105
106
106
- The ` $schema ` property also cannot be combined using the ` $and ` notation ([🔗](#literal-schemas)).
107
-
108
107
Impossible combinations should result in the ` undefined ` type.
109
108
110
109
## Literals Escaping
@@ -132,7 +131,7 @@ It is possible to refer to other **JSON X-Types** using the [JSON Pointer](https
132
131
` ` ` json
133
132
{
134
133
" foo" : {" $ref" : " #/bar" },
135
- " bar" : " [" string " , " number " , " boolean " ]"
134
+ " bar" : [" string" , " number" , " boolean" ]
136
135
}
137
136
` ` `
138
137
@@ -152,23 +151,6 @@ Alternatively, the `$ref` keyword can be used as a prefix which is easier to wri
152
151
153
152
If a reference cannot be resolved, it should be treated as ` any ` .
154
153
155
- ## Literal Schemas
156
-
157
- If something cannot be expressed in terms of **JSON X-Type**, it should go under this key:
158
-
159
- ` ` ` json
160
- {
161
- " $schema" : {
162
- " type" : " string" ,
163
- " contentMediaType" : " application/jwt" ,
164
- " contentSchema" : {" type" : " array" }
165
- }
166
- }
167
- ` ` `
168
-
169
- Note that it's not possible to use **JSON X-Types** inside ` $schema ` .
170
- Additionally, ` $schema ` cannot be used inside ` $and ` operators ([🔗](#types-combining)).
171
-
172
154
## Types Extending
173
155
174
156
Possible extensions are described [here](./extensions.md).
0 commit comments