Sto cercando di capire come impostare required
sul mio array json-schema di oggetti. La proprietà richiesta funziona bene su un oggetto e non su un array.impostazione richiesta su un array json-schema
qui è la parte elementi del mio schema JSON:
"items": {
"type": "array",
"properties": {
"item_id": {"type" : "number"},
"quantity": {"type": "number"},
"price": {"type" : "decimal"},
"title": {"type": "string"},
"description": {"type": "string"}
},
"required": ["item_id","quantity","price","title","description"],
"additionalProperties" : false
}
Ecco l'array JSON io mando sopra. La convalida JSON dovrebbe fallire poiché non sto passando una descrizione in questi articoli.
"items": [
{
"item_id": 1,
"quantity": 3,
"price": 30,
"title": "item1 new name"
},
{
"item_id": 1,
"quantity": 16,
"price": 30,
"title": "Test Two"
}
]
json-schema.org sembra utilizzare v4. – ipengineer