Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Commit b3dc54c

Browse files
authored
Merge pull request #378 from jdesrosiers/fix-learn-schemas
Fix learn schemas
2 parents bd5da62 + ef52582 commit b3dc54c

7 files changed

+102
-102
lines changed

learn/examples/address.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$id": "https://example.com/address.schema.json",
3-
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
44
"description": "An address similar to http://microformats.org/wiki/h-card",
55
"type": "object",
66
"properties": {
@@ -27,7 +27,7 @@
2727
}
2828
},
2929
"required": [ "locality", "region", "country-name" ],
30-
"dependencies": {
30+
"dependentRequired": {
3131
"post-office-box": [ "street-address" ],
3232
"extended-address": [ "street-address" ]
3333
}

learn/examples/calendar.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$id": "https://example.com/calendar.schema.json",
3-
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
44
"description": "A representation of an event",
55
"type": "object",
66
"required": [ "dtstart", "summary" ],
@@ -41,7 +41,7 @@
4141
"type": "string"
4242
},
4343
"geo": {
44-
"$ref": "http://example.com/geographical-location.schema.json"
44+
"$ref": "https://example.com/geographical-location.schema.json"
4545
}
4646
}
4747
}

learn/examples/card.schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$id": "https://example.com/card.schema.json",
3-
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
44
"description": "A representation of a person, company, organization, or place",
55
"type": "object",
66
"required": [ "familyName", "givenName" ],
@@ -61,8 +61,8 @@
6161
}
6262
}
6363
},
64-
"adr": { "$ref": "http://example.com/address.schema.json" },
65-
"geo": { "$ref": "http://example.com/geographical-location.schema.json" },
64+
"adr": { "$ref": "https://example.com/address.schema.json" },
65+
"geo": { "$ref": "https://example.com/geographical-location.schema.json" },
6666
"tz": {
6767
"type": "string"
6868
},

learn/examples/geographical-location.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$id": "https://example.com/geographical-location.schema.json",
3-
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
44
"title": "Longitude and Latitude Values",
55
"description": "A geographical coordinate.",
66
"required": [ "latitude", "longitude" ],

learn/file-system.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,24 @@ We will start with a base JSON Schema expressing the following constraints:
6666

6767
Building out our JSON Schema from top to bottom:
6868

69-
* The [`$id`](http://json-schema.org/latest/json-schema-core.html#rfc.section.8.2) keyword.
70-
* The [`$schema`](http://json-schema.org/latest/json-schema-core.html#rfc.section.7) keyword.
71-
* The [`type`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1) validation keyword.
72-
* The [`required`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.3) validation keyword.
73-
* The [`properties`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.4) validation keyword.
69+
* The [`$id`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.1) keyword.
70+
* The [`$schema`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1) keyword.
71+
* The [`type`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1) validation keyword.
72+
* The [`required`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword.
73+
* The [`properties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.1) validation keyword.
7474
* The `/` key is empty now; We will fill it out later.
75-
* The [`patternProperties`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.5) validation keyword.
75+
* The [`patternProperties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.2) validation keyword.
7676
* This matches other property names via a regular expression. Note: it does not match `/`.
7777
* The `^(/[^/]+)+$` key is empty now; We will fill it out later.
78-
* The [`additionalProperties`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.6) validation keyword.
78+
* The [`additionalProperties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.3) validation keyword.
7979
* The value here is `false` to constrain object properties to be either `/` or to match the regular expression.
8080

8181
> You will notice that the regular expression is explicitly anchored (with `^` and `$`): in JSON Schema, regular expressions (in `patternProperties` and in `pattern`) are not anchored by default.
8282
8383
```json
8484
{
85-
"$id": "http://example.com/fstab",
86-
"$schema": "http://json-schema.org/draft-07/schema#",
85+
"$id": "https://example.com/fstab",
86+
"$schema": "https://json-schema.org/draft/2020-12/schema",
8787
"type": "object",
8888
"required": [ "/" ],
8989
"properties": {
@@ -104,32 +104,32 @@ We saw these keywords in the prior exercise: `$id`, `$schema`, `type`, `required
104104

105105
To this we add:
106106

107-
* The [`description`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.10.1) annotation keyword.
108-
* The [`oneOf`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.7.3) keyword.
109-
* The [`$ref`](http://json-schema.org/latest/json-schema-core.html#rfc.section.8.3) keyword.
107+
* The [`description`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keyword.
108+
* The [`oneOf`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.2.1.3) keyword.
109+
* The [`$ref`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.3.1) keyword.
110110
* In this case, all references used are local to the schema using a relative fragment URI (`#/...`).
111-
* The [`definitions`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.9) keyword.
111+
* The [`$defs`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.4) keyword.
112112
* Including several key names which we will define later.
113113

114114
```json
115115
{
116-
"$id": "http://example.com/entry-schema",
117-
"$schema": "http://json-schema.org/draft-07/schema#",
116+
"$id": "https://example.com/entry-schema",
117+
"$schema": "https://json-schema.org/draft/2020-12/schema",
118118
"description": "JSON Schema for an fstab entry",
119119
"type": "object",
120120
"required": [ "storage" ],
121121
"properties": {
122122
"storage": {
123123
"type": "object",
124124
"oneOf": [
125-
{ "$ref": "#/definitions/diskDevice" },
126-
{ "$ref": "#/definitions/diskUUID" },
127-
{ "$ref": "#/definitions/nfs" },
128-
{ "$ref": "#/definitions/tmpfs" }
125+
{ "$ref": "#/$defs/diskDevice" },
126+
{ "$ref": "#/$defs/diskUUID" },
127+
{ "$ref": "#/$defs/nfs" },
128+
{ "$ref": "#/$defs/tmpfs" }
129129
]
130130
}
131131
},
132-
"definitions": {
132+
"$defs": {
133133
"diskDevice": {},
134134
"diskUUID": {},
135135
"nfs": {},
@@ -142,32 +142,32 @@ To this we add:
142142

143143
Let's now extend this skeleton to add constraints to some of the properties.
144144

145-
* Our `fstype` key uses the [`enum`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.2) validation keyword.
145+
* Our `fstype` key uses the [`enum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.2) validation keyword.
146146
* Our `options` key uses the following:
147147
* The `type` validation keyword (see above).
148-
* The [`minItems`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4.4) validation keyword.
149-
* The [`items`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4.1) validation keyword.
150-
* The [`uniqueItems`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4.5) validation keyword.
148+
* The [`minItems`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.2) validation keyword.
149+
* The [`items`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.1.2) validation keyword.
150+
* The [`uniqueItems`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.3) validation keyword.
151151
* Together these say: `options` must be an array, and the items therein must be strings, there must be at least one item, and all items should be unique.
152152
* We have a `readonly` key.
153153

154154
With these added constraints, the schema now looks like this:
155155

156156
```json
157157
{
158-
"$id": "http://example.com/entry-schema",
159-
"$schema": "http://json-schema.org/draft-07/schema#",
158+
"$id": "https://example.com/entry-schema",
159+
"$schema": "https://json-schema.org/draft/2020-12/schema",
160160
"description": "JSON Schema for an fstab entry",
161161
"type": "object",
162162
"required": [ "storage" ],
163163
"properties": {
164164
"storage": {
165165
"type": "object",
166166
"oneOf": [
167-
{ "$ref": "#/definitions/diskDevice" },
168-
{ "$ref": "#/definitions/diskUUID" },
169-
{ "$ref": "#/definitions/nfs" },
170-
{ "$ref": "#/definitions/tmpfs" }
167+
{ "$ref": "#/$defs/diskDevice" },
168+
{ "$ref": "#/$defs/diskUUID" },
169+
{ "$ref": "#/$defs/nfs" },
170+
{ "$ref": "#/$defs/tmpfs" }
171171
]
172172
},
173173
"fstype": {
@@ -185,7 +185,7 @@ With these added constraints, the schema now looks like this:
185185
"type": "boolean"
186186
}
187187
},
188-
"definitions": {
188+
"$defs": {
189189
"diskDevice": {},
190190
"diskUUID": {},
191191
"nfs": {},
@@ -198,7 +198,7 @@ With these added constraints, the schema now looks like this:
198198

199199
One new keyword is introduced here:
200200

201-
* The [`pattern`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.3.3) validation keyword notes the `device` key must be an absolute path starting with */dev*.
201+
* The [`pattern`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.3.3) validation keyword notes the `device` key must be an absolute path starting with */dev*.
202202

203203
```json
204204
{
@@ -246,7 +246,7 @@ We do have a new key: `label` and the `pattern` validation keyword states it mus
246246

247247
We find another new keyword:
248248

249-
* The [`format`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.7) annotation and assertion keyword.
249+
* The [`format`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.7) annotation and assertion keyword.
250250

251251
```json
252252
{
@@ -276,8 +276,8 @@ We find another new keyword:
276276

277277
Our last definition introduces two new keywords:
278278

279-
* The [`minimum`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.4) validation keyword.
280-
* The [`maximum`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.2) validation keword.
279+
* The [`minimum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword.
280+
* The [`maximum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keword.
281281
* Together these require the size be between 16 and 512, inclusive.
282282

283283
```json
@@ -303,19 +303,19 @@ The resulting schema is quite large:
303303

304304
```json
305305
{
306-
"$id": "http://example.com/entry-schema",
307-
"$schema": "http://json-schema.org/draft-07/schema#",
306+
"$id": "https://example.com/entry-schema",
307+
"$schema": "https://json-schema.org/draft/2020-12/schema",
308308
"description": "JSON Schema for an fstab entry",
309309
"type": "object",
310310
"required": [ "storage" ],
311311
"properties": {
312312
"storage": {
313313
"type": "object",
314314
"oneOf": [
315-
{ "$ref": "#/definitions/diskDevice" },
316-
{ "$ref": "#/definitions/diskUUID" },
317-
{ "$ref": "#/definitions/nfs" },
318-
{ "$ref": "#/definitions/tmpfs" }
315+
{ "$ref": "#/$defs/diskDevice" },
316+
{ "$ref": "#/$defs/diskUUID" },
317+
{ "$ref": "#/$defs/nfs" },
318+
{ "$ref": "#/$defs/tmpfs" }
319319
]
320320
},
321321
"fstype": {
@@ -333,7 +333,7 @@ The resulting schema is quite large:
333333
"type": "boolean"
334334
}
335335
},
336-
"definitions": {
336+
"$defs": {
337337
"diskDevice": {
338338
"properties": {
339339
"type": {
@@ -404,16 +404,16 @@ Coming full circle we use the `$ref` keyword to add our entry schema into the ke
404404

405405
```json
406406
{
407-
"$id": "http://example.com/fstab",
408-
"$schema": "http://json-schema.org/draft-07/schema#",
407+
"$id": "https://example.com/fstab",
408+
"$schema": "https://json-schema.org/draft/2020-12/schema",
409409
"type": "object",
410410
"required": [ "/" ],
411411
"properties": {
412-
"/": { "$ref": "http://example.com/entry-schema" }
412+
"/": { "$ref": "https://example.com/entry-schema" }
413413
},
414414
"patternProperties": {
415-
"^(/[^/]+)+$": { "$ref": "http://example.com/entry-schema" }
415+
"^(/[^/]+)+$": { "$ref": "https://example.com/entry-schema" }
416416
},
417-
"additionalProperties": false,
417+
"additionalProperties": false
418418
}
419419
```

0 commit comments

Comments
 (0)