Describe APIs with flexible schemas, optional properties, and multiple data formats using oneOf
, anyOf
, and allOf
keywords
oneOf
, anyOf
, and allOf
, you can describe APIs that handle different input types or combine multiple schemas into comprehensive data models.
oneOf
, anyOf
, allOf
keywordsallOf
: Combines multiple schemas (like merging objects or extending a base schema). Functions like an and
operator.anyOf
: Accepts data matching any of the provided schemas. Functions like an or
operator.oneOf
: Accepts data matching exactly one of the provided schemas. Functions like an exclusive-or
operator.oneOf
and anyOf
identically since the practical difference rarely affects using the API.not
keyword is currently unsupported.allOf
allOf
, Mintlify performs some preprocessing on your OpenAPI document to display complex combinations in a readable way. For example, when you combine two object schemas with allOf
, Mintlify combines the properties of both into a single object. This becomes especially useful when leveraging OpenAPI’s reusable components.
oneOf
and anyOf
oneOf
or anyOf
, the options are displayed in a tabbed container. Specify a title
field in each subschema to give your options names. For example, here’s how you might display two different types of delivery addresses: