OpenAPI Docs Generator: Swagger to HTML and Markdown
Operator: Abdulla Al Fahad. How tools are built and checked
An OpenAPI file is written for machines, but whoever integrates with the API wants a page that says which endpoints exist, what each takes and returns, and a request they can paste into a terminal. This page produces that locally: paste or open a spec, browse it, and download one HTML file or a Markdown document.
It reads OpenAPI 3.0 and 3.1 and Swagger 2.0, in JSON or YAML. If you only need to convert a YAML file to JSON, the YAML and JSON converter on this site does that; this tool goes further and turns the spec into documentation.
Key features
- OpenAPI 3.x and Swagger 2.0 in JSON or YAML, up to 5 MB, with line and column on parse errors
- Sidebar grouped by tag with an operation filter, plus overview, authentication and schema pages
- Parameter tables merging path-level and operation-level parameters, request bodies by media type, and every response
- Schema tables with nested fields, allOf merged, oneOf and anyOf listed, enums and constraints noted, required fields marked
- Examples built from the schema (example, default, const, enum, then the type and format), or the spec's own example when it has one
- A curl command for each operation with path and required query values filled in, the first security scheme applied, and a JSON, form or multipart body
- Exports: a single self-contained HTML page with no script and no external requests, and Markdown with escaping
What is read from the spec and what the exports contain
References are resolved locally. A $ref that starts with # is looked up as a JSON Pointer in the same document, with ~0 and ~1 and percent-escapes decoded. A reference that points at another file or a URL is shown as an external reference and is never fetched, because the page would then be sending requests on the spec author's behalf. A pointer that does not exist is shown as unresolved. Chains of references are followed up to 20 hops.
Recursive schemas are handled by remembering which references are currently being expanded. When a schema reaches itself again, for example a Pet with a parent that is a Pet, the table shows a row marked circular and stops. A table also stops at 8 levels of nesting and 500 rows, and says so. Generated examples stop at 6 levels and use null where a cycle would continue.
Swagger 2.0 is mapped onto the same model: host, basePath and schemes become the server URL; a body parameter becomes a request body for each type in consumes; formData parameters become an object body, multipart if a file is involved or consumes asks for it; and response schemas are paired with the produces list. Definitions appear under Schemas. OpenAPI 3 server variables are replaced with their default values.
Descriptions are displayed as plain text, in paragraphs. Markdown inside descriptions, which many specs use, is not rendered as formatting: it is shown as written. That is deliberate. Every string in the spec is untrusted, and rendering it as Markdown or HTML would let a hostile spec inject links or markup into the page and into the files you export.
How it works
The YAML reader is the same parser used by the YAML and JSON converter: it supports anchors, aliases and merge keys, and stops with a line and column on anything it cannot read. The result is turned into plain JSON, so YAML-only features such as anchors are expanded before documentation is built. Objects from the spec are only ever read through own-property checks, so keys such as __proto__ or constructor are treated as data and cannot change how the page behaves.
The HTML export is generated by string building with every spec-derived value HTML-escaped, ids restricted to lower-case letters, digits and hyphens, and links limited to http, https and mailto. It includes a Content-Security-Policy that allows inline styles and nothing else, so the file cannot run script or load images and fonts from the network even if something slipped through. The Markdown export escapes punctuation, turns angle brackets into entities, and fences code blocks with a fence longer than any run of backticks inside.
Typical uses
- Sending a partner a readable version of an internal openapi.yaml as a single HTML attachment
- Putting a Markdown API reference into a repository wiki or a pull request description
- Checking how a generated spec reads, including whether schemas, examples and required fields came out as intended
- Getting a curl command for each endpoint to paste into a runbook or a support reply
- Looking at a vendor's Swagger 2.0 file in a form that is easier to scan than the raw YAML
Building one
- Paste the spec, or open a .json, .yaml or .yml file, and press Generate docs.
- Use the sidebar to pick an operation, or the Schemas list for a model; filter by path, summary or method.
- Read the parameters, body and responses, and copy the curl command if you need it.
- Download the HTML for a file you can share, or the Markdown for a repository.
Example
One operation from a small spec
POST /pets (bearerAuth)
requestBody application/json: NewPet { name (required), tag enum dog|cat }
server https://api.petstore.example.com/v1Generated curl
curl -X POST 'https://api.petstore.example.com/v1/pets' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"name":"Rex","tag":"dog"}'
(name uses the schema's example, tag takes the first enum value)Tips for best results
- Add example values to your schemas. The generated body uses them first, so a name of Rex reads better than the placeholder string.
- Put shared fields in components and reference them; the Schemas list then shows each model once, and the tables inside operations name the model they came from.
- Check the circular rows. A schema that refers to itself is legal, but if it surprised you, it often means a parent or children field is wider than intended.
- For a Markdown file that will be published, skim it once: because descriptions are escaped, any Markdown formatting in them appears literally.
Things to check before you rely on it
External references are not followed. A spec split across several files shows those references as external; bundle it into one file first with a tool such as a bundler or redocly bundle, then paste the result.
Examples generated from schemas are plausible, not meaningful. Dates, UUIDs and emails use fixed sample values, and numbers start at zero or the minimum. Treat them as shape illustrations.
The page documents what the spec says; it does not validate it or call the API. A spec with wrong types shows the wrong types.
The curl command uses the first server and the first security requirement only. If your API has several environments or alternative authentication options, adjust the host and header by hand.
Common errors and how to fix them
- "Invalid YAML at line 12, column 5"
- Check indentation and quoting near that line; YAML mixes tabs and spaces badly. A value that contains a colon followed by a space needs quotes.
- "This is not an OpenAPI or Swagger document"
- The top level needs an openapi field such as 3.0.3 or a swagger field of "2.0". Files that hold only a JSON Schema or only a paths fragment are not readable as a full spec.
- "OpenAPI 4.0 is not supported"
- This page reads versions 3.x and Swagger 2.0. A later major version may change the structure, so it is refused rather than half-read.
- A schema shows "external reference" or "unresolved reference"
- External means the $ref points to another file or URL, which is never fetched. Unresolved means a local pointer such as #/components/schemas/Pet does not exist; fix the name or the path.
Best practices
- Keep operationId unique and stable; it becomes the anchor in the HTML export and the identifier clients are generated from.
What the HTML file does and does not contain
The exported file is a single page: inline CSS, a sidebar of anchors, and one section per operation and schema. There is no JavaScript, so there is no search box in the file itself and nothing to break when it is opened from an email attachment or a file share. Layout adapts to narrow screens and to dark mode.
Because the page has no script and its policy blocks every external load, it is safe to host as a static file and it will look the same in ten years. The trade-off is that it is a reference, not an interactive console: there is no Try it out button.
Frequently asked questions
Does it call my API or fetch referenced files?
No. It only reads the text you give it. The server URL appears in the curl commands, but the page never sends a request to it, and references to other files or URLs are marked external, not loaded.
Why are my Markdown descriptions not formatted?
Descriptions are shown as plain text so that a spec cannot inject markup into the page or the exports. Paragraph breaks are kept; bold, links and lists appear as the raw characters.