oneOf, anyOf, allOf
For complex datatypes, OpenAPI provides the oneOf, anyOf, and allOf keywords, allowing you to combine schemas in certain ways. You can read more about these keywords in the Swagger documentation, but essentially:
oneOffunctions like an “exclusive-or” operatoranyOffunctions like an “or” operatorallOffunctions like an “and” operator
The
oneOf and anyOf keywords are treated the same. We have found that, when people use oneOf, they often mean anyOf - and there is often no meaningful difference to the user.The
not keyword is not currently supported.Combining schemas with allOf
Mintlify performs some preprocessing on your OpenAPI document to display these 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.
Providing options with oneOf and anyOf
When you use oneOf or anyOf, Mintlify displays the options in a tabbed container. To give your options helpful names, make sure to give each subschema a title field. For example, here’s how you might display two different types of delivery addresses:
x-codeSamples
If your users interact with your API using an SDK rather than directly through a network request, you can add code samples to your OpenAPI document, and Mintlify will display them in your OpenAPI pages. You can define your code samples using the x-codeSamples extension. This property can be added within any request method, and has the following schema:
The language of the code sample.
The label for the sample. This is useful when providing multiple examples for a single endpoint.
The source code of the sample.
x-hidden and x-excluded
If your pages are autogenerated from an OpenAPI document, but there are some paths that you don’t want to create pages for, you can exclude them from having pages generated by adding the property x-excluded.
If you want to have pages generated, but not have them appear in the navigation, add x-hidden.
You can add the x-hidden or x-excluded tag under endpoint or webhook paths below the method.
Here’s are examples of how that would look in an OpenAPI schema document for an endpoint or a webhook path: