You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/learn/getting-started-step-by-step.md
+15-15
Original file line number
Diff line number
Diff line change
@@ -99,7 +99,7 @@ Using the product catalog example, `productId` is a numeric value that uniquely
99
99
To add the `properties` object to the schema:
100
100
101
101
1. Add the `properties` validation keyword to the end of the schema:
102
-
102
+
103
103
```json
104
104
...
105
105
"title": "Product",
@@ -114,7 +114,7 @@ To add the `properties` object to the schema:
114
114
2. Add the `productId` keyword, along with the following schema annotations:
115
115
*`description`: describes what `productId` is. In this case, it’s the product’s unique identifier.
116
116
*`type`: defines what kind of data is expected. For this example, since the product identifier is a numeric value, use `integer`.
117
-
117
+
118
118
```json
119
119
...
120
120
"properties": {
@@ -174,7 +174,7 @@ This section describes how to specify that certain properties are required. This
174
174
To define a required property:
175
175
176
176
1. Inside the `properties` object, add the `price` key. Include the usual schema annotations `description` and `type`, where `type` is a number:
177
-
177
+
178
178
```json
179
179
"properties": {
180
180
...
@@ -185,7 +185,7 @@ To define a required property:
185
185
```
186
186
187
187
2. Add the `exclusiveMinimum` validation keyword and set the value to zero:
188
-
188
+
189
189
```json
190
190
"price": {
191
191
"description": "The price of the product",
@@ -195,7 +195,7 @@ To define a required property:
195
195
```
196
196
197
197
3. Add the `required` validation keyword to the end of the schema, after the `properties` object. Add `productID`, `productName`, and the new `price` key to the array:
198
-
198
+
199
199
```json
200
200
"price": {
201
201
"description": "The price of the product",
@@ -248,7 +248,7 @@ This section describes how to define an optional property. For this example, def
248
248
To define an optional property:
249
249
250
250
1. Inside the `properties` object, add the `tags` keyword. Include the usual schema annotations `description` and `type`, and define `type` as an array:
251
-
251
+
252
252
```json
253
253
"properties": {
254
254
...
@@ -260,7 +260,7 @@ To define an optional property:
260
260
```
261
261
262
262
2. Add a new validation keyword for `items` to define what appears in the array. For example, `string`:
263
-
263
+
264
264
```json
265
265
"tags": {
266
266
"description": "Tags for the product",
@@ -272,7 +272,7 @@ To define an optional property:
272
272
```
273
273
274
274
3. To make sure there is at least one item in the array, use the `minItems` validation keyword:
275
-
275
+
276
276
```json
277
277
"tags": {
278
278
"description": "Tags for the product",
@@ -285,7 +285,7 @@ To define an optional property:
285
285
```
286
286
287
287
4. To make sure that every item in the array is unique, use the `uniqueItems` validation keyword and set it to `true`:
288
-
288
+
289
289
```json
290
290
"tags": {
291
291
"description": "Tags for the product",
@@ -346,7 +346,7 @@ The earlier examples describe a flat schema with only one level. This section de
346
346
To create a nested data structure:
347
347
348
348
1. Inside the `properties` object, create a new key called `dimensions`:
349
-
349
+
350
350
```json
351
351
"properties": {
352
352
...
@@ -356,15 +356,15 @@ To create a nested data structure:
356
356
```
357
357
358
358
2. Define the `type` validation keyword as `object`:
359
-
359
+
360
360
```json
361
361
"dimensions": {
362
362
"type": "object",
363
363
}
364
364
```
365
365
366
366
3. Add the `properties` validation keyword to contain the nested data structure. Inside the new `properties` keyword, add keywords for `length`, `width`, and `height` that all use the `number` type:
367
-
367
+
368
368
```json
369
369
"dimensions": {
370
370
"type": "object",
@@ -383,7 +383,7 @@ To create a nested data structure:
383
383
```
384
384
385
385
4. To make each of these properties required, add a `required` validation keyword inside the `dimensions` object:
386
-
386
+
387
387
```json
388
388
"dimensions": {
389
389
"type": "object",
@@ -490,7 +490,7 @@ The following schema validates a geographical location:
490
490
To reference this schema in the product catalog schema:
491
491
492
492
1. Inside the `properties` object, add a key named `warehouseLocation`:
493
-
493
+
494
494
```json
495
495
"properties": {
496
496
...
@@ -500,7 +500,7 @@ To reference this schema in the product catalog schema:
500
500
```
501
501
502
502
2. To link to the external geographical location schema, add the `$ref` schema keyword and the schema URL:
503
-
503
+
504
504
```json
505
505
"warehouseLocation": {
506
506
"description": "Coordinates of the warehouse where the product is located.",
0 commit comments