Schema flexibility measures how readily valid data may contain variations or extra fields. A practical rule is to accept flexible requests while sending strict responses. section 7.3
Choose flexibility according to who controls the data:
- Allow additional fields in requests to serve clients that are less strict. section 7.3
- Disallow unexpected fields in responses because the server controls what it sends. section 7.3
- Use additionalProperties: false when a database response must reject fields absent from its schema. section 7.3
A search response with room for variation
A book-search response can require title and available while permitting optional subtitle, page count, subjects, isbn, or isbn_13 fields. Adding dummy_property becomes invalid when additionalProperties is disabled. section 7.3
Listing 7.10 An example of a search response
[
{
"title": "7 Habits of Highly Effective People",
"available": true,
"isbn": "978-0812981605",
"subtitle": "Powerful Lessons in Personal Change",
"number_of_pages": 432
},
{
"title": "The Power of Habit",
"available": false,
"isbn_13": "978-1982137274",
"subtitle": "Why We Do What We Do in Life and Business",
"subjects": [
"Social aspects",
"Habit",
"Change (Psychology)"
]
}
]
Inspect a concrete search response containing different optional fields across book records. section 7.3


