{
"$id": "https://example.com/person.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Person",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "The person's first name."
},
"lastName": {
"type": "string",
"description": "The person's last name."
},
"age": {
"description": "Age in years which must be equal to or greater than zero.",
"type": "integer",
"minimum": 0
}
}
"required": ["firstName", "lastName", "age"]
}
(edited after @gregdennis's answer)
Given the above schema, a valid data would be
{
"firstName": "John",
"lastName": "Doe",
"age": 21
}
But I want to make it "optional", as in I want to allow empty object
// should pass
{}
But not half schemas
// Shouldn't pass
{
"firstName": "John"
}