Skip to content

Commit 98be768

Browse files
committed
remove $schema keyword; describe X-Type with X-Type itself; resolve external $refs
1 parent b076eaa commit 98be768

16 files changed

+913
-239
lines changed

README.md

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
**JSON X-Type** is a data type format for describing JSON-like structures in a simple and natural way.
44
Any [valid JSON](https://www.json.org/) can be validated against a **JSON X-Type** definition.
55

6+
The **JSON X-Type** could be described by itself ([🔗](./x-types.yaml)).
7+
68
## Reserved Keywords
79

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 |
2021

2122
The list can be extended with other `$`-prefixed keywords.
2223
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
103104
104105
The above example results in `foo` being both `string` and `number`, which is effectively equivalent to TypeScript's `never` type.
105106
106-
The `$schema` property also cannot be combined using the `$and` notation ([🔗](#literal-schemas)).
107-
108107
Impossible combinations should result in the `undefined` type.
109108
110109
## Literals Escaping
@@ -132,7 +131,7 @@ It is possible to refer to other **JSON X-Types** using the [JSON Pointer](https
132131
```json
133132
{
134133
"foo": {"$ref": "#/bar"},
135-
"bar": "["string", "number", "boolean"]"
134+
"bar": ["string", "number", "boolean"]
136135
}
137136
```
138137
@@ -152,23 +151,6 @@ Alternatively, the `$ref` keyword can be used as a prefix which is easier to wri
152151
153152
If a reference cannot be resolved, it should be treated as `any`.
154153
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-
172154
## Types Extending
173155
174156
Possible extensions are described [here](./extensions.md).

0 commit comments

Comments
 (0)