-
Notifications
You must be signed in to change notification settings - Fork 245
Update from code changes: document x-mint playground expand setting #7202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,21 @@ | ||
| --- | ||
| title: "OpenAPI setup" | ||
| description: "Generate interactive API documentation from OpenAPI specification files with automatic endpoint pages, request builders, and navigation." | ||
| keywords: ["OpenAPI", "API specification", "Swagger"] | ||
| keywords: | ||
| - "OpenAPI" | ||
| - "API specification" | ||
| - "Swagger" | ||
| --- | ||
|
|
||
| OpenAPI is a specification for describing APIs. Mintlify supports OpenAPI 3.0 and 3.1 documents to generate interactive API documentation and keep it up to date. | ||
|
|
||
|  | ||
|
|
||
| | | | | | ||
| | --- | --- | --- | | ||
| | | | | | ||
| | | | | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty table added to docsMedium Severity An empty three-column markdown table was inserted near the top of the OpenAPI setup page. It has no headers or content and will render as a blank table on the live page. Reviewed by Cursor Bugbot for commit 21accc0. Configure here. |
||
|
|
||
| ## 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](https://swagger.io/specification/). | ||
|
|
@@ -15,30 +25,32 @@ | |
| Reference any number of OpenAPI specifications in the navigation element of your `docs.json` to create pages for your API endpoints. Each specification file generates its own set of endpoints. | ||
|
|
||
| <CodeGroup> | ||
| ```json Single specification | ||
| "navigation": { | ||
| "tabs": [ | ||
| { | ||
| "tab": "API Reference", | ||
| "openapi": "openapi.json" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ```json Multiple specifications | ||
| "navigation": { | ||
| "tabs": [ | ||
| { | ||
| "tab": "API Reference", | ||
| "openapi": [ | ||
| "openapi/v1.json", | ||
| "openapi/v2.json" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| ```json Single specification | ||
| "navigation": { | ||
| "tabs": [ | ||
| { | ||
| "tab": "API Reference", | ||
| "openapi": "openapi.json" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ```json Multiple specifications | ||
| "navigation": { | ||
| "tabs": [ | ||
| { | ||
| "tab": "API Reference", | ||
| "openapi": [ | ||
| "openapi/v1.json", | ||
| "openapi/v2.json" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| </CodeGroup> | ||
|
|
||
| <Note> | ||
|
|
@@ -120,37 +132,35 @@ | |
|
|
||
| <Steps> | ||
| <Step title="Define your authentication method."> | ||
| Add a `securitySchemes` field to define how users authenticate. | ||
| Add a `securitySchemes` field to define how users authenticate. | ||
|
|
||
| This example shows a configuration for bearer authentication. | ||
| This example shows a configuration for bearer authentication. | ||
|
|
||
| ```json | ||
| { | ||
| "components": { | ||
| "securitySchemes": { | ||
| "bearerAuth": { | ||
| "type": "http", | ||
| "scheme": "bearer" | ||
| ```json | ||
| { | ||
| "components": { | ||
| "securitySchemes": { | ||
| "bearerAuth": { | ||
| "type": "http", | ||
| "scheme": "bearer" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ``` | ||
| </Step> | ||
| <Step title="Apply authentication to your endpoints."> | ||
| Add a `security` field to require authentication. | ||
| Add a `security` field to require authentication. | ||
|
|
||
| ```json | ||
| { | ||
| "security": [ | ||
| ```json | ||
| { | ||
| "bearerAuth": [] | ||
| "security": [ | ||
| { | ||
| "bearerAuth": [] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ``` | ||
| </Step> | ||
| </Steps> | ||
|
|
||
|
|
@@ -168,7 +178,7 @@ | |
|
|
||
| Use the `x-default` extension on a security scheme to pre-fill the authentication field in the API playground. This is useful for providing placeholder values or test credentials that help users get started quickly. | ||
|
|
||
| ```json {6} | ||
| ```json highlight={6} | ||
| { | ||
| "components": { | ||
| "securitySchemes": { | ||
|
|
@@ -183,7 +193,7 @@ | |
| } | ||
| ``` | ||
|
|
||
| The `x-default` extension supports `apiKey` and `http` bearer security scheme types. The value appears as the default input in the playground's authentication fields. Prefill for security schemes is unconditional and does not require any additional configuration. | ||
|
|
||
| Use `x-default` on other schema properties in your OpenAPI specification to set a default value in the API playground without affecting the `default` field in the schema definition. Unlike security schemes, prefill for non-security-scheme properties only takes effect when you set [`api.examples.prefill`](/organize/settings-api) to `true` in your [`docs.json`](/api-playground/overview#example-configuration). | ||
|
|
||
|
|
@@ -200,7 +210,7 @@ | |
| When enabled, clicking the option downloads your OpenAPI spec directly. Deployments with multiple specs receive them bundled as `api-specs.zip`. On deployments behind `auth` or `userAuth`, only authenticated readers can download the spec. | ||
|
|
||
| <Warning> | ||
| The downloaded OpenAPI spec is unfiltered and does not respect [authentication groups](/deploy/authentication-setup). Any authenticated reader who can open the contextual menu receives the full spec, including endpoints and schemas that would otherwise be hidden from their group. Do not enable `download-spec` on an authenticated site if your OpenAPI spec contains endpoints or fields you consider sensitive. | ||
|
Check warning on line 213 in api-playground/openapi-setup.mdx
|
||
| </Warning> | ||
|
|
||
| ## Customize your endpoint pages | ||
|
|
@@ -211,7 +221,7 @@ | |
|
|
||
| Override the default metadata for generated API pages by adding `x-mint: metadata` to any operation. You can use any metadata field that would be valid in MDX frontmatter except for `openapi`. | ||
|
|
||
| ```json {7-14} | ||
| ```json highlight={7-14} | ||
| { | ||
| "paths": { | ||
| "/users": { | ||
|
|
@@ -239,7 +249,7 @@ | |
|
|
||
| You can also control playground display per endpoint using the `playground` and `groups` metadata fields: | ||
|
|
||
| ```json {7-11} | ||
| ```json highlight={7-11} | ||
| { | ||
| "paths": { | ||
| "/admin/users": { | ||
|
|
@@ -264,7 +274,7 @@ | |
|
|
||
| Add content before the auto-generated API documentation using `x-mint: content`. The `x-mint: content` extension supports all Mintlify MDX components and formatting. | ||
|
|
||
| ```json {6-8} | ||
| ```json highlight={6-8} | ||
| { | ||
| "paths": { | ||
| "/users": { | ||
|
|
@@ -317,7 +327,7 @@ | |
|
|
||
| Both fields accept an array of strings. Each string becomes its own pill. | ||
|
|
||
| ```json {7-10} | ||
| ```json highlight={7-10} | ||
| { | ||
| "components": { | ||
| "schemas": { | ||
|
|
@@ -351,13 +361,36 @@ | |
|
|
||
| With this configuration, a property like `{ "type": "string", "nullable": true, "x-internal": "admin" }` renders `nullable` and `admin` pills next to its name. Post pills appear in this order: built-in pills (`read-only`, `write-only`), then `api.params.post` config-driven pills, then per-property `x-mint.post` pills. | ||
|
|
||
| ### Collapse nested playground fields | ||
|
|
||
| Start nested object fields collapsed in the API playground by adding `x-mint: playground` with `expand: false` to an operation. This keeps the playground compact for endpoints with large or deeply nested request bodies. | ||
|
|
||
| ```json highlight={6-10} | ||
| { | ||
| "paths": { | ||
| "/users": { | ||
| "post": { | ||
| "summary": "Create user", | ||
| "x-mint": { | ||
| "playground": { | ||
| "expand": false | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| The top-level request sections, such as Authorization, Path, Query, and Body, always stay expanded. The setting only collapses object fields nested within those sections. Users can expand any collapsed field manually. When `expand` is omitted, all fields start expanded. | ||
|
|
||
| ### Group display names | ||
|
|
||
| Set a custom display name for a tag's navigation group using the `x-group` extension on a tag object. By default, Mintlify uses the tag `name` as both the navigation group label and the URL path segment. The `x-group` extension overrides the group label while keeping the tag name for the URL. | ||
|
|
||
| This is useful when you want a human-readable group name that differs from the tag used in your API paths. | ||
|
|
||
| ```json {4-9} | ||
| ```json highlight={4-9} | ||
| { | ||
| "tags": [ | ||
| { | ||
|
|
@@ -409,7 +442,7 @@ | |
|
|
||
| Generate dedicated API sections by adding an `openapi` field to a navigation element and no other pages. All endpoints in the specification appear in the generated section. | ||
|
|
||
| ```json {5} | ||
| ```json highlight={5} | ||
| "navigation": { | ||
| "tabs": [ | ||
| { | ||
|
|
@@ -515,7 +548,7 @@ | |
|
|
||
| Reference specific endpoints without setting a default OpenAPI specification by including the file path. You can reference endpoints from multiple OpenAPI specifications in the same documentation section. | ||
|
|
||
| ```json {5-6} | ||
| ```json highlight={5-6} | ||
| "navigation": { | ||
| "pages": [ | ||
| "introduction", | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental favicon image in docs
Medium Severity
A
Faviconimage was inserted at the top of the OpenAPI setup page. It is unrelated to thex-mint.playground.expanddocumentation and will render on the live page.Reviewed by Cursor Bugbot for commit 21accc0. Configure here.