Converts a swagger-definition into a static html page
This package contains a template, partials and styles for bootprint to convert Swagger-Specifications into a static HTML-page.
In order to use bootprint-swagger
from the command line
you have to install bootprint
and bootprint-swagger
globally:
npm install -g bootprint
npm install -g bootprint-swagger
Check this out: You can now try out the new bootprint-swagger playground. Just paste a Swagger-specification and make it readable.
bootprint swagger http://petstore.swagger.io/v2/swagger.json target
The directory "target" should now contain a file index.html
and main.css
which contain a readble
form of the Swagger-Petstore-Example.
For details about command line parameters, please refer to the documentation of the Bootprint
bootprint-swagger
is just a template-module for bootprint
. That means, it contains
LessCss-file, Handlebars-partials and a
preprocessor that converts
a Swagger-Specification into the JSON actually needed by the templates.
If you want to have a single HTML-file, not one HTML and one CSS, you can use substack's html-inline package to generate a self-cotnained file:
npm -g install html-inline
html-inline target/index.html
The does essentially the same, just in a the above command line, just in JavaScript (i.e. node
)
// Load bootprint
require('bootprint')
// Load bootprint-swagger
.load(require('bootprint-swagger'))
// Customize configuration, override any options
.merge({ /* Any other configuration */})
// Specify build source and target
.build('http://petstore.swagger.io/v2/swagger.json', 'target')
// Generate swagger-documentation into "target" directory
.generate()
.done(console.log)
The API of Bootprint-Swagger consists of Handlebars-partials that can be overridden and LessCss-Definitions, that can be adapted.
About 26 Handlebars partials are used to render this swagger-html-page. The following documentation is not final yet and there are a lot of partials without real documentation, but you may already have a look at it: The partials documentation describes the partials in use and the order in which they are called. You can override these partials in a Bootprint configuration file.
bootprint-swagger
is published under the MIT-license.
See for details.
Some of the example specs have been provided by contributors who opened issues on github,
those files are in the test/*
-directories.
**test/all-of/swagger.json** [msh321](https://github.com/msh321) (issue #35)
**test/missing-items/swagger.json** [asieira](https://github.com/asieira) (issue #18)
**test/read-only-property/swagger.json** [asieira](https://github.com/asieira) (issue #28)
For release notes, see CHANGELOG.md
See CONTRIBUTING.md.