Schema strictness is the choice between accepting unspecified fields and rejecting them. In JSON Schema, extra object fields are allowed by default; setting additionalProperties to false makes the schema strict. section 7.3
A harmless field—or a contract bug?
A database response containing dummy_property may look harmless because unused fields are ignored. But a response schema can reject it by setting additionalProperties to false. A practical rule is to accept extra fields in client requests while strictly controlling server responses: be liberal in what you accept and conservative in what you send. section 7.3
Listing 7.15 Disallowing properties not mentioned in the schema
var booksFromDBSchema = {
"type": "array",
"items": {
"type": "object",
"required": ["title", "isbn", "available"],
"additionalProperties": false,
"properties": {
"title": {"type": "string"},
"available": {"type": "boolean"},
"isbn": {"type": "string"}
}
}
};
See the strict database-response schema that rejects properties not explicitly listed. section 7.3
