Skip to content

x-mint migrate script #1023

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
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion api-playground/migrating-from-mdx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,51 @@
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. This can help you reduce the number of files you need to maintain and improve the consistency of your API documentation.

Check warning on line 8 in api-playground/migrating-from-mdx.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

api-playground/migrating-from-mdx.mdx#L8

Did you really mean 'autogenerating'?

You can define metadata and content for each endpoint in your OpenAPI specification and organize endpoints where you want them in your navigation.

## Migration steps
## CLI migration

The `mint migrate-mdx` command is the recommended way to migrate from MDX endpoint pages to autogenerated pages.

Check warning on line 14 in api-playground/migrating-from-mdx.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

api-playground/migrating-from-mdx.mdx#L14

Did you really mean 'autogenerated'?

This command:
- Parses your `docs.json` navigation structure.
- Identifies MDX pages that reference OpenAPI endpoints.
- Extracts content from MDX files and moves it to the `x-mint` extension in your OpenAPI specification.
- Migrates any existing `x-mcp` data into `x-mint`.
- Updates your `docs.json` to reference the OpenAPI endpoints directly instead of MDX files.
- Deletes the original MDX endpoint files.

<Info>
If you already have `x-mint` defined for an endpoint and also have an MDX page with content for that endpoint, the MDX content will overwrite existing `x-mint` settings.

If you have multiple MDX pages for the same endpoint with different content, the script will use the content from the page that appears last in your `docs.json`.

The migration tool does not support previewing changes before applying them.
</Info>

<Steps>
<Step title="Prepare your OpenAPI specification.">
Ensure your OpenAPI specification is valid and includes all endpoints you want to document.

Any MDX pages you want to migrate must have the `openapi:` frontmatter referencing an endpoint.

<Tip>
Validate your OpenAPI file using the [Swagger Editor](https://editor.swagger.io/) or [Mint CLI](https://www.npmjs.com/package/mint).
</Tip>
</Step>
<Step title="Install the Mint CLI">
If needed, install or update the [Mint CLI](/installation).
</Step>
<Step title="Run the migration command.">
```bash
mint migrate-mdx
```
</Step>
</Steps>

## Manual migration steps

<Steps>
<Step title="Prepare your OpenAPI specification.">
Expand Down
10 changes: 10 additions & 0 deletions installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@
mint rename <oldFilename> <newFilename>
```

### Migrating MDX endpoint pages

You can migrate MDX endpoint pages to autogenerated pages from your OpenAPI specification using the following command:

Check warning on line 131 in installation.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

installation.mdx#L131

Did you really mean 'autogenerated'?

```bash
mint migrate-mdx
```

This command converts individual MDX endpoint pages to autogenerated pages defined in your `docs.json`, moves MDX content to the `x-mint` extension in your OpenAPI specification, and updates your navigation. See [Migrating from MDX](/api-playground/migrating-from-mdx) for detailed information.

Check warning on line 137 in installation.mdx

View check run for this annotation

Mintlify / Mintlify Validation (mintlify) - vale-spellcheck

installation.mdx#L137

Did you really mean 'autogenerated'?

## Formatting

While developing locally, we recommend using extensions in your IDE to recognize and format `MDX` files.
Expand Down