liveBook · Manning

Schema flexibility

As explained in Data-Oriented Programming: Reduce software complexity

Schema flexibility is the degree to which a schema permits variations or additional fields in valid data.

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

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Demonstrates optional fields and additionalProperties configuration, stopping short of broader validation internals.
Examples
Uses book-search responses, database responses, optional book fields, and dummy properties to contrast permissive and strict schemas.
What you can do after
Configure validation schemas that accept or reject fields beyond required properties.
How it connects
Connects schema flexibility with data validation, schemas, requests, responses, and additional properties.

Also explained in

Compare how 3 books explain schema flexibility →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming: Reduce software complexity. The section links point to the parts of the book it draws on.