You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api-playground/mdx/configuration.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: 'MDX setup'
3
3
description: 'Generate docs pages for your API endpoints using `MDX`'
4
4
---
5
5
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, MDXcan 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.
7
7
8
8
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.
@@ -10,6 +10,8 @@ OpenAPI is a specification for describing APIs. Mintlify supports OpenAPI 3.0+ d
10
10
11
11
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/).
12
12
13
+
You can create API pages from a single or multiple OpenAPI documents.
14
+
13
15
### Describing your API
14
16
15
17
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
93
95
94
96
For more information on defining and applying authentication, see [Authentication](https://swagger.io/docs/specification/authentication/) in the OpenAPI documentation.
95
97
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
+
96
184
## Auto-populate API pages
97
185
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.
99
187
100
-
The metadata for the generated pages will have the following default values:
188
+
Generated endpoint pages have these default metadata values:
101
189
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.
106
194
107
195
<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.
109
197
</Tip>
110
198
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:
112
207
113
208
```json {5}
114
209
"navigation": {
@@ -121,20 +216,27 @@ The metadata for the generated pages will have the following default values:
121
216
}
122
217
```
123
218
124
-
### Example with navigation groups
219
+
You can use multiple OpenAPI specifications in different navigation sections:
125
220
126
-
```json {8-11}
221
+
```json {8-11, 15-18}
127
222
"navigation": {
128
223
"tabs": [
129
224
{
130
225
"tab": "API Reference",
131
226
"groups": [
132
227
{
133
-
"group": "Endpoints",
228
+
"group": "Users",
134
229
"openapi": {
135
230
"source": "/path/to/openapi-1.json",
136
231
"directory": "api-reference"
137
232
}
233
+
},
234
+
{
235
+
"group": "Admin",
236
+
"openapi": {
237
+
"source": "/path/to/openapi-2.json",
238
+
"directory": "api-reference"
239
+
}
138
240
}
139
241
]
140
242
}
@@ -143,12 +245,14 @@ The metadata for the generated pages will have the following default values:
143
245
```
144
246
145
247
<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.
147
249
</Note>
148
250
149
251
## Create `MDX` files for API pages
150
252
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).
152
256
153
257
### Manually specify files
154
258
@@ -158,6 +262,10 @@ When you reference an OpenAPI operation this way, the name, description, paramet
158
262
159
263
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.
160
264
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
+
161
269
If you want to reference an external OpenAPI file, add the file's URL to your `docs.json`.
Copy file name to clipboardExpand all lines: api-playground/overview.mdx
+12-8Lines changed: 12 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,9 +33,9 @@ We recommend generating your API playground from an OpenAPI specification. See [
33
33
34
34
</Step>
35
35
<Steptitle="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.
39
39
40
40
```json
41
41
{
@@ -104,17 +104,21 @@ You can customize your API playground by defining the following properties in yo
104
104
105
105
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.
106
106
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.
108
110
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:
110
112
111
113
- Customize page metadata
112
114
- Add additional content like examples
113
-
- Hide specific operations
114
-
- Reorder pages in your navigation
115
115
- Control playground behavior per page
116
116
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).
0 commit comments