validate using jsonschema, not manually
This commit is contained in:
parent
a2cbbb2068
commit
2f183c758f
4 changed files with 125 additions and 70 deletions
36
schemas/recipe.json
Normal file
36
schemas/recipe.json
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://example.com/recipe.json",
|
||||
"title": "Recipe",
|
||||
"description": "Recipe",
|
||||
"type": "object",
|
||||
"required": [ "title" ],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"title": { "type": "string" },
|
||||
"ingredients": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$id": "https://example.com/ingredient.json",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [ "name" ],
|
||||
"properties": {
|
||||
"name": { "type": "string" },
|
||||
"amount": { "type": "number" },
|
||||
"unit": { "type": "string" },
|
||||
"or": { "items": { "$ref": "/ingredient.json" } },
|
||||
"note": { "type": "string" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"steps": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
},
|
||||
"parts": {
|
||||
"type": "array",
|
||||
"items": { "$ref": "/recipe.json" }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue