Skip to content

Commit fa34cdf

Browse files
authored
Reflected New OpenAPI setup (#518)
* Reflected New OpenAPI setup * Added CLI ref
1 parent 3f32ffd commit fa34cdf

File tree

2 files changed

+56
-55
lines changed

2 files changed

+56
-55
lines changed

api-playground/openapi/setup.mdx

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,47 @@ description: "Reference OpenAPI endpoints in your docs pages"
88
To describe your endpoints with OpenAPI, make sure you have a valid OpenAPI
99
document in either JSON or YAML format that follows the
1010
[OpenAPI specification](https://swagger.io/specification/). Your document must
11-
follow OpenAPI specification 3.0+.
11+
follow OpenAPI specification 3.0+.
12+
<Tip>To validate your OpenAPI spec, use our [CLI](https://www.npmjs.com/package/mintlify) and run this command: <br/>`mintlify openapi-check <openapiFilenameOrUrl>`</Tip>
1213

1314
## Auto-populate API pages
1415

15-
The fastest way to get started with OpenAPI is to add an `openapi` field to a tab or anchor in the `docs.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.
16+
The fastest way to get started with OpenAPI is to add an `openapi` field to a tab in the `docs.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.
1617

17-
**Example with Anchors:**
1818

19+
**Example with Tabs:**
1920
```json {5}
20-
{
21-
"anchors": [
21+
"navigation": {
22+
"tabs": [
2223
{
23-
"name": "API Reference",
24-
"openapi": "/path/to/openapi.json",
25-
"url": "api-reference",
26-
"icon": "square-terminal"
24+
"tab": "API Reference",
25+
"openapi": "https://petstore3.swagger.io/api/v3/openapi.json"
2726
}
2827
]
2928
}
3029
```
30+
![](/images/autogeneration-with-tabs.png)
3131

32-
![](/images/anchors-autogeneration-anchors.png)
33-
34-
**Example with Tabs:**
35-
36-
```json {6}
37-
{
32+
**Example with Groups:**
33+
```json {8-11}
34+
"navigation": {
3835
"tabs": [
3936
{
40-
"name": "API Reference",
41-
"url": "api-reference",
42-
"openapi": "https://petstore3.swagger.io/api/v3/openapi.json"
37+
"tab": "API Reference",
38+
"groups": [
39+
{
40+
"group": "Endpoints",
41+
"openapi": {
42+
"source": "/path/to/openapi-1.json",
43+
"directory": "api-reference"
44+
}
45+
}
46+
]
4347
}
4448
]
4549
}
4650
```
4751

48-
![](/images/autogeneration-with-tabs.png)
49-
50-
<Tip>To validate your OpenAPI spec, you can use this command: <br/>`mintlify openapi-check <openapiFilenameOrUrl>`</Tip>
51-
52-
5352
When using this option, the metadata for the generated pages will have the following default values:
5453

5554
* `title`: The `summary` field from the OpenAPI operation, if present. Otherwise a title generated from the HTTP method and endpoint.
@@ -62,39 +61,9 @@ There are some scenarios in which the default behavior isn't sufficient. If you
6261

6362
## Create MDX files for API pages
6463

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).&#x20;
66-
67-
![](/images/elevenlabs-mdx-autogeneration-example.png)
68-
69-
### Autogenerate files
70-
71-
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.
72-
73-
Our Mintlify [scraper](https://www.npmjs.com/package/@mintlify/scraping)
74-
autogenerates MDX files for your OpenAPI endpoints. Use the relative path to the
75-
OpenAPI document in your codebase.
76-
77-
```bash
78-
npx @mintlify/scraping@latest openapi-file <path-to-openapi-file>
79-
```
80-
81-
Add the `-o` flag to specify a folder to populate the files into. If a folder is
82-
not specified, the files will populate in the working directory.
83-
84-
```bash
85-
npx @mintlify/scraping@latest openapi-file <path-to-openapi-file> -o api-reference
86-
```
87-
88-
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.
64+
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/mindsdb/mindsdb/blob/main/docs/rest/databases/create-databases.mdx) from [MindsDB](https://docs.mindsdb.com/rest/databases/create-databases).&#x20;
9465

95-
<Note>
96-
If your OpenAPI document is invalid, the files will not autogenerate.
97-
</Note>
66+
![](/images/mindsdb.png)
9867

9968
### Manually specify files
10069

@@ -132,6 +101,38 @@ only one OpenAPI file - it will automatically detect your OpenAPI file.
132101
the page will be empty.
133102
</Note>
134103

104+
### Autogenerate files
105+
106+
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.
107+
108+
Our Mintlify [scraper](https://www.npmjs.com/package/@mintlify/scraping)
109+
autogenerates MDX files for your OpenAPI endpoints. Use the relative path to the
110+
OpenAPI document in your codebase.
111+
112+
```bash
113+
npx @mintlify/scraping@latest openapi-file <path-to-openapi-file>
114+
```
115+
116+
Add the `-o` flag to specify a folder to populate the files into. If a folder is
117+
not specified, the files will populate in the working directory.
118+
119+
```bash
120+
npx @mintlify/scraping@latest openapi-file <path-to-openapi-file> -o api-reference
121+
```
122+
123+
Learn more about our scraping package [here](https://www.npmjs.com/package/@mintlify/scraping).
124+
125+
The scraper will output an array of
126+
[Navigation entries](/settings/global#structure) containing your OpenAPI MDX
127+
files. You can either append these entries to your existing Navigation, or
128+
reorder and add the files to your navigation manually.
129+
130+
<Note>
131+
If your OpenAPI document is invalid, the files will not autogenerate.
132+
</Note>
133+
134+
135+
135136
## Create MDX files for OpenAPI schemas
136137

137138
Mintlify also allows you to create individual pages for any OpenAPI schema

images/mindsdb.png

762 KB
Loading

0 commit comments

Comments
 (0)