Add an OpenAPI specification file
To document your endpoints with OpenAPI, you need one or more valid OpenAPI specifications in either JSON or YAML format that follow the OpenAPI specification 3.0 or 3.1. Add OpenAPI specifications to your documentation repository or host them online where you can access the specifications by URL. Specifications stored in your repository are served as downloadable files at their path on your docs domain.Mintlify supports
$ref for internal references only within a single OpenAPI document. External references are not supported.Describe your API
We recommend the following resources to learn about and construct your OpenAPI specification:- Swagger’s OpenAPI Guide to learn the OpenAPI syntax
- The OpenAPI specification to reference details of the latest specification
- Swagger Editor to edit, validate, and debug your OpenAPI document
- The Mint CLI to validate your OpenAPI document with
mint openapi-check <filename>
Specify the base URL for your API
To enable the API playground, add aservers field to your OpenAPI specification with your API’s base URL.
/users/{id} or simply /. The base URL defines where these paths should be appended.
The API playground uses these server URLs to determine where to send requests. If you specify multiple servers, a dropdown allows users to toggle between servers.
Specify authentication
To enable authentication in your API documentation and playground, configure thesecuritySchemes and security fields in your OpenAPI specification.
Define your authentication method
Add a
securitySchemes field to define how users authenticate.This example shows a configuration for bearer authentication.- API Keys: For header, query, or cookie-based keys
- Bearer: For JWT or OAuth tokens
- Basic: For username and password
If different endpoints require different authentication methods, you can override the security field per operation.
Customize your endpoint pages
Customize your endpoint pages by adding thex-mint extension to your OpenAPI specification. The x-mint extension provides additional control over how your API documentation is generated and displayed.
Metadata
Override the default metadata for generated API pages by addingx-mint: metadata to any operation. You can use any metadata field that would be valid in MDX frontmatter except for openapi.
playground and groups metadata fields:
admin group.
Content
Add content before the auto-generated API documentation usingx-mint: content. The x-mint: content extension supports all Mintlify MDX components and formatting.
Href
Set the URL of the autogenerated endpoint page usingx-mint: href. When x-mint: href is present, the generated API page uses the specified URL instead of the default autogenerated URL.
Auto-populate API pages
Add anopenapi field to any navigation element in your docs.json to automatically generate pages for OpenAPI endpoints.
The openapi field accepts either a file path in your docs repo or a URL to a hosted OpenAPI document.
There are two approaches for adding endpoint pages into your documentation:
Dedicated API sections
Generate dedicated API sections by adding anopenapi field to a navigation element. All endpoints in the specification are included.
The
directory field is optional and specifies where generated API pages are stored in your docs repo. If not specified, defaults to the api-reference directory.Selective endpoints
When you want more control over where endpoints appear in your documentation, you can reference specific endpoints in your navigation.Set a default OpenAPI spec
Configure a default OpenAPI specification for a navigation element, then reference specific endpoints in thepages field:
METHOD /path generates an API page for that endpoint using the default OpenAPI specification.
OpenAPI spec inheritance
OpenAPI specifications are inherited down the navigation hierarchy. Child navigation elements inherit their parent’s OpenAPI specification unless they define their own.Create MDX pages from your OpenAPI specification
For more granular control over individual endpoint pages, create MDX pages from your OpenAPI specification. This lets you customize page metadata, content, and reorder or exclude pages in your navigation.Document endpoints
Create a page for each endpoint and specify which OpenAPI operation to display using theopenapi field in the frontmatter.
Autogenerate endpoint pages
To autogenerate MDX files from your OpenAPI specification, use the Mintlify scraper:Document data models
Create a page for each data structure defined in your OpenAPI specification’scomponents.schemas using the openapi-schema field in the frontmatter.
Webhooks
Webhooks are HTTP callbacks that your API sends to notify external systems when events occur. Webhooks are supported in OpenAPI 3.1+ documents. Add awebhooks field to your OpenAPI document alongside the paths field.
To create an MDX page for a webhook (OpenAPI 3.1+), use webhook instead of an HTTP method:
webhooks field.