-
Notifications
You must be signed in to change notification settings - Fork 189
x-mint
#927
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
Open
ethanpalm
wants to merge
22
commits into
main
Choose a base branch
from
x-mint
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
x-mint
#927
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
2924b1f
add troubleshooting info
ethanpalm 0ae7f5f
update conceptual info in MDX setup
ethanpalm 3f1ad1d
add OpenAPI section to navigation page
ethanpalm b5e4203
update overview steps
ethanpalm 567c6e6
Update info about customizing endpoint pages
ethanpalm 5236130
update setup information
ethanpalm e78661f
fix typo
ethanpalm b7982d2
add migration guide
ethanpalm 02a5ae6
clarify allowed metadata
ethanpalm ec90f25
more precise terms
ethanpalm bf1d98c
explain `directory` field
ethanpalm be7ae75
clarify you can use multiple OpenAPI specs
ethanpalm 095bec3
Merge branch 'main' into x-mint
ethanpalm 215b00d
navigation reviewer feedback
ethanpalm e382793
troubleshooting reviewer feedback
ethanpalm a9c61cd
overview reviewer feedback
ethanpalm 3b09774
setup reviewer feedback
ethanpalm 63f6480
fewer things to troubleshoot
ethanpalm 7fe0562
update auto-populate API pages section
ethanpalm b56e3f2
remove navigation content
ethanpalm aea6fb4
Merge branch 'main' into x-mint
ethanpalm c45f385
reviewer feedback
ethanpalm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
--- | ||
title: "Migrating MDX API pages to OpenAPI navigation" | ||
sidebarTitle: "Migrating from MDX" | ||
description: "Update from individual MDX endpoint pages to automated OpenAPI generation with flexible navigation" | ||
icon: "arrow-big-right-dash" | ||
--- | ||
|
||
If you are currently using individual `MDX` pages for your API endpoints, you can migrate to autogenerating pages from your OpenAPI specification while retaining the customizability of individual pages. | ||
|
||
You can define metadata and content for each endpoint in your OpenAPI specification and organize endpoints precisely where you want them in your navigation. | ||
|
||
Follow this migration guide to start building your API documentation from your OpenAPI specification with these benefits: | ||
|
||
- Automatic page generation from your OpenAPI spec | ||
- Flexible navigation options | ||
- Fewer files to maintain | ||
- Consistent API documentation format | ||
|
||
## Before: Individual MDX pages | ||
|
||
Previously, you created separate MDX files for each endpoint and referenced them in your navigation: | ||
|
||
```json | ||
{ | ||
"navigation": [ | ||
{ | ||
"group": "API Reference", | ||
"pages": [ | ||
"api/get-users", | ||
"api/post-users", | ||
"api/delete-users" | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
Each endpoint required its own MDX file with manual configuration and content. | ||
|
||
## After: OpenAPI navigation | ||
|
||
When you complete the migration, you will reference your OpenAPI specification directly in navigation and automatically generate endpoint pages: | ||
|
||
```json | ||
{ | ||
"navigation": [ | ||
{ | ||
"group": "API Reference", | ||
"openapi": "openapi.json" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
Or selectively include specific endpoints: | ||
|
||
```json | ||
{ | ||
"navigation": [ | ||
{ | ||
"group": "API Reference", | ||
"openapi": "openapi.json", | ||
"pages": [ | ||
"GET /users", | ||
"POST /users", | ||
"DELETE /users" | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Migration steps | ||
|
||
<Steps> | ||
<Step title="Prepare your OpenAPI specification."> | ||
Ensure your OpenAPI specification is valid and includes all endpoints you want to document. | ||
|
||
For any endpoints that you want to customize the metadata or content, add the `x-mint` extension to the endpoint. See [x-mint extension](/api-playground/openapi-setup#x-mint-extension) for more details. | ||
|
||
For any endpoints that you want to exclude from your documentation, add the `x-hidden` extension to the endpoint. | ||
|
||
<Info> | ||
Validate your OpenAPI file using the [Swagger Editor](https://editor.swagger.io/) or [Mint CLI](https://www.npmjs.com/package/mint). | ||
</Info> | ||
</Step> | ||
|
||
<Step title="Update your navigation structure."> | ||
Replace `MDX` page references with OpenAPI endpoints in your `docs.json`. | ||
|
||
```json | ||
{ | ||
"navigation": { | ||
"openapi": "/path/to/openapi.json", | ||
"pages": [ | ||
"introduction", | ||
"GET /health", | ||
"quickstart", | ||
"POST /users", | ||
"GET /users/{id}", | ||
"advanced-features" | ||
] | ||
} | ||
} | ||
``` | ||
|
||
</Step> | ||
|
||
<Step title="Remove old MDX files."> | ||
After verifying your new navigation works correctly, remove the `MDX` endpoint files that you no longer need. | ||
</Step> | ||
</Steps> | ||
|
||
## Navigation patterns | ||
|
||
You can customize how your API documentation appears in your navigation. | ||
|
||
### Mixed content navigation | ||
|
||
Combine automatically generated API pages with other pages: | ||
|
||
```json | ||
{ | ||
"navigation": [ | ||
{ | ||
"group": "API Reference", | ||
"openapi": "openapi.json", | ||
"pages": [ | ||
"api/overview", | ||
"GET /users", | ||
"POST /users", | ||
"api/authentication" | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### Multiple API versions | ||
|
||
Organize different API versions using tabs or groups: | ||
|
||
```json | ||
{ | ||
"navigation": { | ||
"tabs": [ | ||
{ | ||
"tab": "API v1", | ||
"openapi": "specs/v1.json" | ||
}, | ||
{ | ||
"tab": "API v2", | ||
"openapi": "specs/v2.json" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
## When to use individual `MDX` pages | ||
|
||
Consider keeping individual `MDX` pages when you need: | ||
|
||
- Extensive custom content per endpoint like React components or lengthy examples | ||
- Unique page layouts | ||
- Experimental documentation approaches for specific endpoints | ||
|
||
For most use cases, OpenAPI navigation provides better maintainability and consistency. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.