liveBook · Manning

Optional type property

As explained in The Design of Web APIs, Second Edition

An optional property is an object property that need not be present in an instance because its name is absent from the applicable required list.

An optional property may be absent because its name is not included in the applicable required list. For input objects, consumers may omit it; for output objects, the API may omit it. section 7.4.6

Product resource

A Product schema requires productReference, name, category, price, and dateAdded. Description, keywords, and isProductUnavailable remain optional because they are absent from required. A nested supplier object can define its own required list. section 7.4.6

Optionality also supports compatible API evolution: make previously required input data optional or add new optional data. Consumers that do not know the new property can continue sending earlier requests. section 15.2.2

How The Design of Web APIs, Second Edition covers it

How deep it goes
Explains required lists, nested object schemas, and backward-compatible input changes, but does not detail validation implementation.
Examples
Uses Product fields, a nested supplier object, and an optional transfer reason object to demonstrate omission and conditional requirements.
What it assumes
Uses object schemas, properties, and required lists while distinguishing input obligations from output guarantees.
What you can do after
Configure JSON Schema required lists and assess whether API input or output changes remain compatible.
How it connects
Connects optional properties with JSON Schema, OpenAPI, API consumers, and backward compatibility.

Also explained in

Compare how 2 books explain optional type property →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.