Yet another static html generator for Open API 2.0 / Swagger 2.0
npm install openapi2htmlYet another static html generator for Open API 2.0 / Swagger 2.0. It generates Bootstrap 4 compatible static html from your Swagger API spec. Not all the Swagger features are supported -- if you miss anything, let me know.
!main workflow



![node]()

![License Status]()
``bash`
npm install openapi2html
First, use swagger-parser to parse your api from json or yaml. Then, use openapi2html to generate html, e.g.:`js
const parser = require('swagger-parser');
const openapi2html = require('openapi2html');
...
const api = await parser.parse('my-api.yaml');
const html = openapi2html(api);
`
openapi2html may take a second parameter for options, e.g.:`js`
...
const options = {
tagColors: {
pet: 'primary',
store: 'warning',
user: 'success'
},
show: {
host: false
}
};
const html = openapi2html(api, options);tagColors
There are the following options:
* maps your operations' tags to Bootstrap theme colors primary, secondary, success, danger, warning, info, light, dark. Please do not use danger because this is already used for deprecated. The default theme color is secondary. If you use custom colors, you need to provide the according CSS classes, e.g., badge-mycolor. Hex color values are not supported.show
* is used for switching on or off certain information. The following is supported: version (default true), host (default true), basePath (default true), contact (default false), license (default false), termsOfService (default false), schemes (default true), consumes (default true), produces (default true)
The generated html doesn't provide any styling. It is plain Bootstrap 4 compatible html, i.e.,
it uses
through , , , as well as Bootstrap's Card and Badge components.
In addition, there are classes o2h-* attached such as
o2h-operation-get to allow some customized styling.This is what worked for me:
`html
...
``