Readme OpenAPI Dedupe Command
A page whose body is set up for Mintlify's OpenAPI-driven layout (an openapi: "/openapi/<file> METHOD /path" frontmatter key, added by wcc readme openapi) already renders that operation's description automatically. If the page body just repeats the same description verbatim, it renders twice.
wcc readme openapi-dedupe finds pages where this has happened and wraps the body in an MDX comment ({/* ... */}) so the source is preserved but nothing renders twice.
Usage
wcc readme openapi-dedupe [options]
Typically run after wcc readme openapi:
wcc readme convert
wcc readme openapi
wcc readme openapi-dedupe
Options
| Option | Description | Default |
|---|---|---|
-f, --file <path> | Fix a single MDX file directly | — |
-d, --dir <path> | Fix MDX files in a specific directory | pages/reference |
--openapi-dir <dir> | Directory of OpenAPI spec files to check page bodies against | openapi |
--dry-run | Preview changes without writing files | false |
--quiet | Suppress terminal output | false |
How it works
For each .mdx file:
- Reads the frontmatter
openapikey (/openapi/<file> METHOD /path) and looks up that spec file under--openapi-dir. - Compares the page body (trimmed) to that operation's
descriptionfield in the spec. - If they match exactly, wraps the body in
{/* ... */}.
Files with no openapi key, no matching spec, no description on that operation, or a body that doesn't match are left untouched — as are bodies already wrapped in a comment (idempotent).
{/* Before */}
---
title: "Get User"
openapi: "/openapi/getuser.json GET /users/{id}"
---
Fetches a user by ID.
{/* After */}
---
title: "Get User"
openapi: "/openapi/getuser.json GET /users/{id}"
---
{/*
Fetches a user by ID.
*/}
Config file
Set defaults in config.json to run wcc readme openapi-dedupe without arguments:
{
"readme": {
"openapi-dedupe": {
"file": null,
"dir": null,
"openapi-dir": "openapi",
"dry-run": false,
"quiet": false
}
}
}