Skip to main content

Update MDX Files from OpenAPI

After changing API routes (for example on localhost:9001), the Docusaurus OpenAPI docs must be regenerated so the MDX files reflect the new spec. The plugin does not overwrite existing files, so you need to clean the generated docs first, then regenerate them.

Prerequisites

  • The API serving the OpenAPI/Swagger spec must be running (e.g. http://localhost:9001).
  • The spec URL is configured in docusaurus.config.ts (e.g. http://localhost:9001/api-docs/exame.json for exam routes).

Steps

1. Clean the generated API docs

Remove the existing generated MDX files and sidebar for the plugin you want to update. Use the plugin ID defined in docusaurus.config.ts.

To clean all specs of a given plugin (e.g. exam routes only):

bash
pnpm docusaurus clean-api-docs all -p <plugin-id>

Example — clean only exam routes:

bash
pnpm docusaurus clean-api-docs all -p legacy-api-exam-routes

Example — clean all API docs (all plugins):

bash
pnpm docusaurus clean-api-docs all

If you have more than one OpenAPI plugin, you must use -p <plugin-id>. Otherwise the command will ask you to specify the plugin.

2. Regenerate the API docs

Regenerate the MDX files from the current OpenAPI spec. Ensure the API is running so the spec URL is reachable.

To regenerate only the docs for one plugin:

bash
pnpm gen-api-docs -p <plugin-id>

Example — regenerate exam routes:

bash
pnpm gen-api-docs -p legacy-api-exam-routes

Example — regenerate all API docs:

bash
pnpm gen-api-docs

3. Verify

Check that the updated routes and schemas appear in docs/openapi/legacy-api/<category>/ and that the sidebar and MDX content match your API.

Quick reference

GoalCommand
Clean exam docs onlypnpm docusaurus clean-api-docs all -p legacy-api-exam-routes
Regenerate exam docspnpm gen-api-docs -p legacy-api-exam-routes
Clean + regenerate examRun the two commands above in order
Clean all API docspnpm docusaurus clean-api-docs all (use -p if multiple plugins)
Regenerate allpnpm gen-api-docs

Plugin IDs (from docusaurus.config.ts)

  • legacy-api — legacy API
  • legacy-api-exam-routes — exam routes
  • legacy-api-authentication-routes — authentication routes
  • legacy-api-logout-routes — logout routes

Use the same plugin ID for both clean-api-docs and gen-api-docs when updating a specific set of routes.