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/openapi/setup.mdx
+70-91Lines changed: 70 additions & 91 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,35 +3,47 @@ title: "OpenAPI Setup"
3
3
description: "Reference OpenAPI endpoints in your docs pages"
4
4
---
5
5
6
-
## Add an OpenAPI specification file
6
+
## Adding Your OpenAPI Spec
7
7
8
-
To describe your endpoints with OpenAPI, make sure you have a valid OpenAPI
9
-
document in either JSON or YAML format that follows the
10
-
[OpenAPI specification](https://swagger.io/specification/). Your document must
11
-
follow OpenAPI specification 3.0+.
8
+
### Format Requirements
9
+
Make sure your OpenAPI document follows these requirements:
10
+
- Valid JSON or YAML format
11
+
- Follows OpenAPI specification 3.0+
12
+
- Contains complete endpoint and schema definitions
12
13
13
-
## Auto-populate API pages
14
+
### Validating Your Spec
15
+
Before proceeding, validate your OpenAPI spec using our CLI tool:
14
16
15
-
The fastest way to get started with OpenAPI is to add an `openapi` field to a tab or anchor in the `mint.json`. This field can contain either the path to an OpenAPI document in your docs repo, or the URL of a hosted OpenAPI document. Mintlify will automatically generate a page for each OpenAPI operation and place them in the tab/anchor.
17
+
```bash
18
+
mintlify openapi-check <openapiFilenameOrUrl>
19
+
```
20
+
21
+
## Auto-Generation Options
16
22
17
-
**Example with Anchors:**
23
+
You have two main options for automatically generating API documentation from your OpenAPI spec:
24
+
25
+
### Using Anchors
26
+
Add the OpenAPI spec to an anchor in your `mint.json` to generate pages under that section:
18
27
19
28
```json {5}
20
29
{
21
30
"anchors": [
22
31
{
23
32
"name": "API Reference",
24
-
"openapi": "/path/to/openapi.json",
33
+
"openapi": "/path/to/openapi.json",// Local path or URL
*`version`: The `version` value from the anchor or tab, if present.
64
+
### Generated Page Metadata
65
+
Auto-generated pages will include the following metadata by default:
60
66
61
-
There are some scenarios in which the default behavior isn't sufficient. If you need more customizability, you can create an MDX page for your OpenAPI operation, and modify it just like any other MDX page.
67
+
-**Title**: Uses the OpenAPI operation's `summary` field, or generates one from the HTTP method and endpoint
68
+
-**Description**: Uses the OpenAPI operation's `description` field if present
69
+
-**Version**: Inherits the `version` from the parent anchor or tab if specified
62
70
63
-
## Create MDX files for API pages
71
+
## Custom MDX Pages
64
72
65
-
If you want to customize the page metadata, add additional content, omit certain OpenAPI operations, or reorder OpenAPI pages in your navigation, you'll need an MDX page for each operation. Here is [an example MDX OpenAPI page](https://github.com/elevenlabs/elevenlabs-docs/blob/e5e267c97b8d1e4c21db1dcdb8b005eb1dfed7da/api-reference/speech-to-speech.mdx?plain=1#L2) from [Elevenlabs](https://elevenlabs.io/docs/api-reference/speech-to-speech). 
73
+
For more control over your API documentation, you can create individual MDX pages for each operation.
For large OpenAPI documents, creating one MDX page for each OpenAPI operation can be a lot of work. To make it easier, we created a local OpenAPI page scraper.
Learn more about our scraping package [here](https://www.npmjs.com/package/@mintlify/scraping).
89
-
90
-
The scraper will output an array of
91
-
[Navigation entries](/settings/global#structure) containing your OpenAPI MDX
92
-
files. You can either append these entries to your existing Navigation, or
93
-
reorder and add the files to your navigation manually.
94
-
95
93
<Note>
96
-
If your OpenAPI document is invalid, the files will not autogenerate.
94
+
The scraper requires a valid OpenAPI document. Invalid specs will cause the generation to fail.
97
95
</Note>
98
96
99
-
### Manually specify files
100
-
101
-
You can always create an MDX page manually, and reference the OpenAPI operation in the page's metadata using the `openapi` field.
102
-
103
-
<Snippetfile="api-playground/openapi.mdx" />
104
-
105
-
By using the OpenAPI reference, the name, description, parameters, responses,
106
-
and the API playground will be automatically generated from the OpenAPI document.
107
-
108
-
If you have multiple OpenAPI files, include the path to the OpenAPI file to ensure Mintlify finds the correct OpenAPI document. This is not required if you have
109
-
only one OpenAPI file - it will automatically detect your OpenAPI file.
97
+
### Manual Page Creation
98
+
You can also create pages manually by referencing OpenAPI operations in your page metadata:
110
99
111
100
<CodeGroup>
112
-
```md Example
113
-
---
114
-
title: "Get users"
115
-
openapi: "/path/to/openapi-1.json GET /users"
116
-
---
117
-
```
118
-
119
-
```md Format
120
-
---
121
-
title: "title of the page"
122
-
openapi: openapi-file-path method path
123
-
---
124
-
```
125
-
</CodeGroup>
101
+
```md Single OpenAPI File
102
+
---
103
+
title: "Get Users"
104
+
openapi: "GET /users"
105
+
---
106
+
```
126
107
127
-
<br />
108
+
```md Multiple OpenAPI Files
109
+
---
110
+
title: "Get Users"
111
+
openapi: "/path/to/openapi-1.json GET /users"
112
+
---
113
+
```
114
+
</CodeGroup>
128
115
129
116
<Note>
130
-
The method and path must match the method and path specified in the OpenAPI
131
-
document exactly. If the endpoint doesn't exist in the OpenAPI file,
132
-
the page will be empty.
117
+
The method and path must exactly match your OpenAPI specification. Mismatches will result in empty pages.
133
118
</Note>
134
119
135
-
## Create MDX files for OpenAPI schemas
120
+
## Schema Documentation
136
121
137
-
Mintlify also allows you to create individual pages for any OpenAPI schema
138
-
defined in an OpenAPI document's `components.schemas` field:
122
+
### Creating Schema Pages
123
+
Generate standalone pages for your OpenAPI schemas defined in `components.schemas`:
139
124
140
-
<CodeGroup>
141
-
```md Example
142
-
---
143
-
openapi-schema: OrderItem
144
-
---
145
-
```
146
-
147
-
```md Format
148
-
---
149
-
openapi-schema: "schema-key"
150
-
---
151
-
```
152
-
</CodeGroup>
125
+
```md
126
+
---
127
+
openapi-schema: "OrderItem"
128
+
---
129
+
```
130
+
131
+
This automatically creates a page documenting the structure and properties of your schema.
Copy file name to clipboardExpand all lines: development.mdx
+67-37Lines changed: 67 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,17 @@ title: 'Local Development'
3
3
description: 'Preview changes locally to update your docs'
4
4
---
5
5
6
+
## Prerequisites
7
+
6
8
<Info>
9
+
Please make sure you have **Node.js version 19 or higher** installed before proceeding with the setup.
10
+
</Info>
7
11
8
-
**Prerequisite**: Please install Node.js (version 19 or higher) before proceeding.
12
+
## Installation
9
13
10
-
</Info>
14
+
### Installing Mintlify CLI
11
15
12
-
**Step 1**: Install Mintlify:
16
+
You can install Mintlify globally on your system using your preferred package manager:
13
17
14
18
<CodeGroup>
15
19
@@ -27,13 +31,9 @@ description: 'Preview changes locally to update your docs'
27
31
28
32
</CodeGroup>
29
33
30
-
**Step 2**: Navigate to the docs directory (where the `mint.json` file is located) and execute the following command:
31
-
32
-
```bash
33
-
mintlify dev
34
-
```
34
+
### Alternative Installation
35
35
36
-
Alternatively, if you do not want to install Mintlify globally you can use a run script available:
36
+
If you prefer not to install Mintlify globally, you can use it directly through package manager execution commands:
37
37
38
38
<CodeGroup>
39
39
```bash npm
@@ -51,31 +51,47 @@ Alternatively, if you do not want to install Mintlify globally you can use a run
51
51
</CodeGroup>
52
52
53
53
<Warning>
54
-
Yarn's "dlx" run script requires yarn version >2. See [here](https://yarnpkg.com/cli/dlx) for more information.
54
+
If you're using Yarn's "dlx" command, note that it requires Yarn version >2. Learn more about dlx [here](https://yarnpkg.com/cli/dlx).
55
55
</Warning>
56
56
57
-
A local preview of your documentation will be available at `http://localhost:3000`.
57
+
## Running Locally
58
+
59
+
### Starting the Development Server
60
+
61
+
1. Navigate to your docs directory (where the `mint.json` file is located)
62
+
2. Run the following command:
63
+
64
+
```bash
65
+
mintlify dev
66
+
```
67
+
68
+
Your documentation preview will be available at `http://localhost:3000`.
58
69
59
-
### Custom Ports
70
+
### Port Configuration
60
71
61
-
By default, Mintlify uses port 3000. You can customize the port Mintlify runs on by using the `--port` flag. To run Mintlify on port 3333, for instance, use this command:
72
+
#### Default Port
73
+
74
+
By default, Mintlify runs on port 3000. You can customize this using the `--port` flag:
62
75
63
76
```bash
64
77
mintlify dev --port 3333
65
78
```
66
79
67
-
If you attempt to run Mintlify on a port that's already in use, it will use the next available port:
80
+
#### Port Conflicts
81
+
82
+
If your specified port is already in use, Mintlify will automatically try the next available port:
68
83
69
-
```md
84
+
```bash
70
85
Port 3000 is already in use. Trying 3001 instead.
71
86
```
72
87
73
-
## Mintlify Versions
88
+
## Maintenance
74
89
75
-
Please note that each CLI release is associated with a specific version of Mintlify. If your local website doesn't align with the production version, please update the CLI:
90
+
### Version Management
76
91
77
-
<CodeGroup>
92
+
The CLI version needs to match Mintlify's platform version. If you notice discrepancies between local and production previews, update your CLI:
78
93
94
+
<CodeGroup>
79
95
```bash npm
80
96
npm i -g mintlify@latest
81
97
```
@@ -87,45 +103,59 @@ Please note that each CLI release is associated with a specific version of Mintl
87
103
```bash pnpm
88
104
pnpm up --global mintlify
89
105
```
90
-
91
106
</CodeGroup>
92
107
93
-
##Validating Links
108
+
### Link Validation
94
109
95
-
The CLI can assist with validating reference links made in your documentation. To identify any broken links, use the following command:
110
+
Check for broken references in your documentation using:
96
111
97
112
```bash
98
113
mintlify broken-links
99
114
```
100
115
101
-
## Deployment
116
+
## Development Tools
117
+
118
+
### Code Editor Setup
102
119
103
-
If the deployment is successful, you should see the following:
120
+
For the best development experience, we recommend:
121
+
122
+
1.[MDX VSCode extension](https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-mdx) for syntax highlighting
123
+
2.[Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) for code formatting
124
+
125
+
### Deployment Verification
126
+
127
+
After a successful deployment, you should see a confirmation screen:
alt="Deployment success screen showing all checks passed"
109
134
/>
110
135
</Frame>
111
136
112
-
## Code Formatting
113
-
114
-
We suggest using extensions on your IDE to recognize and format MDX. If you're a VSCode user, consider the [MDX VSCode extension](https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-mdx) for syntax highlighting, and [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) for code formatting.
115
-
116
137
## Troubleshooting
117
138
118
139
<AccordionGroup>
119
-
<Accordiontitle='Error: Could not load the "sharp" module using the darwin-arm64 runtime'>
120
-
121
-
This may be due to an outdated version of node. Try the following:
122
-
1. Remove the currently-installed version of mintlify: `npm remove -g mintlify`
123
-
2. Upgrade to Node v19 or higher.
124
-
3. Reinstall mintlify: `npm install -g mintlify`
140
+
<Accordiontitle='Module Loading Error (Sharp)'>
141
+
If you encounter the error: "Could not load the sharp module using the darwin-arm64 runtime", follow these steps:
142
+
143
+
1. Remove existing Mintlify installation:
144
+
```bash
145
+
npm remove -g mintlify
146
+
```
147
+
2. Upgrade Node.js to v19 or higher
148
+
3. Reinstall Mintlify:
149
+
```bash
150
+
npm install -g mintlify
151
+
```
125
152
</Accordion>
126
153
127
-
<Accordiontitle="Issue: Encountering an unknown error">
128
-
129
-
Solution: Go to the root of your device and delete the \~/.mintlify folder. Afterwards, run `mintlify dev` again.
0 commit comments