OpenAPI describes the shape of API data using JSON Schema’s primitive types
(string, number, integer, boolean, array, object, null) refined by
an optional format keyword. Choosing the right type/format pair makes generated
clients, server stubs and documentation accurate. This reference lists the common
combinations and their semantics.
How it works
Every schema in an OpenAPI document has a type. For scalar types a format
narrows the meaning — for example type: string, format: date-time means an
RFC 3339 timestamp, and type: integer, format: int64 means a 64-bit integer.
Tooling uses these to pick the right language type (e.g. OffsetDateTime,
UUID, long) when generating code. In OpenAPI 3.1, schemas are pure JSON
Schema 2020-12, so null is expressed with type arrays rather than the old
nullable keyword.
Nullable in 3.0 vs 3.1
# OpenAPI 3.0
nickname:
type: string
nullable: true
# OpenAPI 3.1 (JSON Schema 2020-12)
nickname:
type: [string, "null"]
Notes and tips
Treat format as a hint: many validators ignore formats they do not recognise,
so add explicit constraints (pattern, minimum, maxLength) when correctness
matters. Because JSON and JavaScript cannot represent the full int64 range
safely, large identifiers are often modelled as type: string even though they
are numeric. Custom formats are allowed and simply pass through as documentation.