Skip to content

Commit f632ff1

Browse files
authored
x-mint (#927)
* add troubleshooting info * update conceptual info in MDX setup * add OpenAPI section to navigation page * update overview steps * Update info about customizing endpoint pages * update setup information * fix typo * add migration guide * clarify allowed metadata * more precise terms * explain `directory` field * clarify you can use multiple OpenAPI specs * navigation reviewer feedback * troubleshooting reviewer feedback * overview reviewer feedback * setup reviewer feedback * fewer things to troubleshoot * update auto-populate API pages section * remove navigation content * reviewer feedback
1 parent b359742 commit f632ff1

File tree

4 files changed

+138
-24
lines changed

4 files changed

+138
-24
lines changed

api-playground/mdx/configuration.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: 'MDX setup'
33
description: 'Generate docs pages for your API endpoints using `MDX`'
44
---
55

6-
You can manually define API endpoints in individual `MDX` files rather than using an OpenAPI specification. This method provides flexibility for custom content, but we recommend generating API documentation from an OpenAPI specification file for most API documentation projects as it's more maintainable and feature-rich. However, MDX can be useful for documenting small APIs, prototyping, or when you want to feature API endpoints alongside other content.
6+
You can manually define API endpoints in individual `MDX` files rather than using an OpenAPI specification. This method provides flexibility for custom content, but we recommend generating API documentation from an OpenAPI specification file for most projects because it is more maintainable and feature-rich. However, creating `MDX` pages for an API can be useful to document small APIs, prototyping, or when you want more control over where API endpoints are in the navigation.
77

88
To generate pages for API endpoints using `MDX`, configure your API settings in `docs.json`, create individual `MDX` files for each endpoint, and use components like `<ParamFields />` to define parameters. From these definitions, Mintlify generates interactive API playgrounds, request examples, and response examples.
99

api-playground/openapi-setup.mdx

Lines changed: 121 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ OpenAPI is a specification for describing APIs. Mintlify supports OpenAPI 3.0+ d
1010

1111
To document your endpoints with OpenAPI, you need a valid OpenAPI document in either JSON or YAML format that follows the [OpenAPI specification 3.0\+](https://swagger.io/specification/).
1212

13+
You can create API pages from a single or multiple OpenAPI documents.
14+
1315
### Describing your API
1416

1517
We recommend the following resources to learn about and construct your OpenAPI documents.
@@ -93,22 +95,115 @@ If different endpoints within your API require different methods of authenticati
9395

9496
For more information on defining and applying authentication, see [Authentication](https://swagger.io/docs/specification/authentication/) in the OpenAPI documentation.
9597

98+
## `x-mint` extension
99+
100+
The `x-mint` extension is a custom OpenAPI extension that provides additional control over how your API documentation is generated and displayed.
101+
102+
### Metadata
103+
104+
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`, `version`, or `deprecated`:
105+
106+
```json {7-13}
107+
{
108+
"paths": {
109+
"/users": {
110+
"get": {
111+
"summary": "Get users",
112+
"description": "Retrieve a list of users",
113+
"x-mint": {
114+
"metadata": {
115+
"title": "List all users",
116+
"description": "Fetch paginated user data with filtering options",
117+
"og:title": "Display a list of users",
118+
}
119+
},
120+
"parameters": [
121+
{
122+
// Parameter configuration
123+
}
124+
]
125+
}
126+
}
127+
}
128+
}
129+
```
130+
131+
### Content
132+
133+
Add content before the auto-generated API documentation using `x-mint: content`:
134+
135+
```json {6-13}
136+
{
137+
"paths": {
138+
"/users": {
139+
"post": {
140+
"summary": "Create user",
141+
"x-mint": {
142+
"content": "## Prerequisites\n\nThis endpoint requires admin privileges and has rate limiting.\n\n<Note>User emails must be unique across the system.</Note>"
143+
},
144+
"parameters": [
145+
{
146+
// Parameter configuration
147+
}
148+
]
149+
}
150+
}
151+
}
152+
}
153+
```
154+
155+
The `content` extension supports all Mintlify MDX components and formatting.
156+
157+
### href
158+
159+
Change the URL of the endpoint page in your docs using `x-mint: href`:
160+
161+
```json {6-8, 14-16}
162+
{
163+
"paths": {
164+
"/legacy-endpoint": {
165+
"get": {
166+
"summary": "Legacy endpoint",
167+
"x-mint": {
168+
"href": "/deprecated-endpoints/legacy-endpoint"
169+
}
170+
}
171+
},
172+
"/documented-elsewhere": {
173+
"post": {
174+
"summary": "Special endpoint",
175+
"x-mint": {
176+
"href": "/guides/special-endpoint-guide"
177+
}
178+
}
179+
}
180+
}
181+
}
182+
```
183+
96184
## Auto-populate API pages
97185

98-
You can add an `openapi` field to any navigation element in your `docs.json` to auto-populate your docs with a page for each specified endpoint. The `openapi` field can contain the path to an OpenAPI document in your docs repo or the URL of a hosted OpenAPI document.
186+
Add an `openapi` 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.
99187

100-
The metadata for the generated pages will have the following default values:
188+
Generated endpoint pages have these default metadata values:
101189

102-
- `title`: The `summary` field from the OpenAPI operation, if present. Otherwise a title generated from the HTTP method and endpoint.
103-
- `description`: The `description` field from the OpenAPI operation, if present.
104-
- `version`: The `version` value from the anchor or tab, if present.
105-
- `deprecated`: The `deprecated` field from the OpenAPI operation, if present. If `true`, a deprecated label will appear next to the endpoint title in the side navigation and on the endpoint page.
190+
- `title`: The operation's `summary` field, if present. If there is no `summary`, the title is generated from the HTTP method and endpoint.
191+
- `description`: The operation's `description` field, if present.
192+
- `version`: The `version` value from the parent anchor or tab, if present.
193+
- `deprecated`: The operation's `deprecated` field. If `true`, a deprecated label will appear next to the endpoint title in the side navigation and on the endpoint page.
106194

107195
<Tip>
108-
If you have some endpoints in your OpenAPI schema that you want to exclude from your auto-populated API pages, add the [x-hidden](/api-playground/customization/managing-page-visibility#x-hidden) property to the endpoint.
196+
To exclude specific endpoints from your auto-generated API pages, add the [x-hidden](/api-playground/customization/managing-page-visibility#x-hidden) property to the operation in your OpenAPI spec.
109197
</Tip>
110198

111-
### Example with navigation tabs
199+
There are two approaches for adding endpoint pages into your documentation:
200+
201+
1. **Dedicated API sections**: Reference OpenAPI specs at the navigation level for dedicated API sections.
202+
2. **Selective endpoints**: Reference specific endpoints in your navigation alongside other pages.
203+
204+
### Dedicated API sections
205+
206+
Generate complete API sections by adding an `openapi` field to any navigation element. All endpoints in the specification will be included:
112207

113208
```json {5}
114209
"navigation": {
@@ -121,20 +216,27 @@ The metadata for the generated pages will have the following default values:
121216
}
122217
```
123218

124-
### Example with navigation groups
219+
You can use multiple OpenAPI specifications in different navigation sections:
125220

126-
```json {8-11}
221+
```json {8-11, 15-18}
127222
"navigation": {
128223
"tabs": [
129224
{
130225
"tab": "API Reference",
131226
"groups": [
132227
{
133-
"group": "Endpoints",
228+
"group": "Users",
134229
"openapi": {
135230
"source": "/path/to/openapi-1.json",
136231
"directory": "api-reference"
137232
}
233+
},
234+
{
235+
"group": "Admin",
236+
"openapi": {
237+
"source": "/path/to/openapi-2.json",
238+
"directory": "api-reference"
239+
}
138240
}
139241
]
140242
}
@@ -143,12 +245,14 @@ The metadata for the generated pages will have the following default values:
143245
```
144246

145247
<Note>
146-
The directory field is optional. If not specified, the files will be placed in the `api-reference` directory of the docs repo.
248+
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 of your repo.
147249
</Note>
148250

149251
## Create `MDX` files for API pages
150252

151-
If you want to customize the page metadata, add additional content, omit certain OpenAPI operations, or reorder OpenAPI pages in your navigation, you can create `MDX` pages for each operation. See an [example MDX OpenAPI page from MindsDB](https://github.com/mindsdb/mindsdb/blob/main/docs/rest/databases/create-databases.mdx?plain=1) and how it appears in their [live documentation](https://docs.mindsdb.com/rest/databases/create-databases).
253+
For control over individual endpoint pages, create `MDX` pages for each operation. This lets you customize page metadata, add content, omit certain operations, or reorder pages in your navigation at the page level.
254+
255+
See an [example MDX OpenAPI page from MindsDB](https://github.com/mindsdb/mindsdb/blob/main/docs/rest/databases/create-databases.mdx?plain=1) and how it appears in their [live documentation](https://docs.mindsdb.com/rest/databases/create-databases).
152256

153257
### Manually specify files
154258

@@ -158,6 +262,10 @@ When you reference an OpenAPI operation this way, the name, description, paramet
158262

159263
If you have multiple OpenAPI files, include the file path in your reference to ensure Mintlify finds the correct OpenAPI document. If you have only one OpenAPI file, Mintlify will detect it automatically.
160264

265+
<Note>
266+
This approach works regardless of whether you have set a default OpenAPI spec in your navigation. You can reference any endpoint from any OpenAPI spec by including the file path in the frontmatter.
267+
</Note>
268+
161269
If you want to reference an external OpenAPI file, add the file's URL to your `docs.json`.
162270

163271
<CodeGroup>

api-playground/overview.mdx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ We recommend generating your API playground from an OpenAPI specification. See [
3333

3434
</Step>
3535
<Step title="Configure `docs.json`.">
36-
Update your `docs.json` to reference your OpenAPI specification. You can add an `openapi` property to any navigation element to auto-populate your docs with a page for each endpoint specified in your OpenAPI document.
37-
38-
In this example, Mintlify will generate a page for each endpoint specified in `openapi.json` and organize them under the "API reference" group in your navigation.
36+
Update your `docs.json` to reference your OpenAPI specification. Add an `openapi` property to any navigation element to auto-populate your docs with pages for each endpoint specified in your OpenAPI document.
37+
38+
This example generates a page for each endpoint specified in `openapi.json` and organize them under the "API reference" group in your navigation.
3939

4040
```json
4141
{
@@ -104,17 +104,21 @@ You can customize your API playground by defining the following properties in yo
104104

105105
This example configures the API playground to be interactive with example code snippets for cURL, Python, and JavaScript. Only required parameters are shown in the code snippets.
106106

107-
### Custom `MDX` pages
107+
### Custom endpoint pages
108+
109+
When you need more control over your API documentation, use the `x-mint` extension in your OpenAPI specification or create individual `MDX` pages for your endpoints.
108110

109-
When you need more control over your API documentation, create individual `MDX` pages for your endpoints. This allows you to:
111+
Both options allow you to:
110112

111113
- Customize page metadata
112114
- Add additional content like examples
113-
- Hide specific operations
114-
- Reorder pages in your navigation
115115
- Control playground behavior per page
116116

117-
See [MDX Setup](/api-playground/mdx/configuration) for more information on creating individual pages for your API endpoints.
117+
The `x-mint` extension is recommended so that all of your API documentation is automatically generated from your OpenAPI specification and maintained in one file.
118+
119+
Individual `MDX` pages are recommended for small APIs or when you want to experiment with changes on a per-page basis.
120+
121+
For more information, see [x-mint extension](/api-playground/openapi-setup#x-mint-extension) and [MDX Setup](/api-playground/mdx/configuration).
118122

119123
## Further reading
120124

navigation.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ Anchors that strictly contain external links can be achieved using the `global`
249249
}
250250
```
251251

252+
---
253+
252254
## Dropdowns
253255

254256
Dropdowns show up in the same place as anchors, but are consolidated into a single dropdown.
@@ -296,7 +298,7 @@ While not required, we also recommend that you set an icon for each dropdown ite
296298

297299
## Versions
298300

299-
Versions can be leveraged to partition your navigation into different versions.
301+
Partition your navigation into different versions.
300302

301303
<img
302304
className="block dark:hidden pointer-events-none"
@@ -337,7 +339,7 @@ Versions can be leveraged to partition your navigation into different versions.
337339

338340
## Languages
339341

340-
Languages can be leveraged to partition your navigation into different languages.
342+
Partition your navigation into different languages.
341343

342344
<img
343345
className="block dark:hidden pointer-events-none"

0 commit comments

Comments
 (0)