Export your Swagger/OpenAPI docs as a single offline HTML file for easy sharing and viewing—no server required!
- Generates a single
api-docs.htmlfile with your full Swagger UI and spec embedded - No need to serve or host JSON files
- Works with any Swagger/OpenAPI endpoint that exposes
swagger-ui-init.js - Simple CLI usage
npm install -g swagger-htmlYou can find it here.
https://www.npmjs.com/package/swagger-html
swagger-html <base URL for your swagger docs> [options](optional)-o, --output <file>: Specify output file or directory. If omitted, the default isswagger-api-docs.htmlin your current directory.- If a directory is given, the file will be named
swagger-api-docs.htmlinside that directory. - If a filename is given, it will ensure the name ends with
.html.
- If a directory is given, the file will be named
--versioned: Append the API version to the output filename (e.g.,swagger-api-docs-v1.0.0.html).
swagger-html http://localhost:3000/api-docsThis will generate a HTML file in the current directory. Open it in your browser to view your API docs offline.
or
swagger-html http://localhost:3000/api-docs -o docs --versionedThis will generate a versioned HTML file in the docs directory. Open it in your browser to view your API docs offline.
- Fetches your Swagger UI's
swagger-ui-init.jsfile - Extracts the OpenAPI JSON
- Embeds it directly into a standalone HTML file using Swagger UI
- Node.js v16 or newer
MIT
- You can contribute to the project here https://github.com/jirugutema/swagger-html
- To contribute, fork the repository, create a new branch, and submit a pull request.
- Make sure to update the documentation as needed.
Developed by JiruGutema