Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openapi2html

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi2html

Yet another static html generator for Open API 2.0 / Swagger 2.0

  • 1.0.0-alpha.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
311
decreased by-41.32%
Maintainers
1
Weekly downloads
 
Created
Source

openapi2html

Yet 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.

build status Coverage Status Dependency Status Greenkeeper badge Maintainability FOSSA Status node code style License Status

Install

npm install --save openapi2html

Usage

const parser = require('swagger-parser');
const openapi2html = require('openapi2html');

...
const api = await parser.parse('my-api.yaml');
const html = openapi2html(api);

Styling

The generated html doesn't provide any styling. It is plain Bootstrap 4 compatible html, i.e., it uses <h1> through <h6>, <code>, <a>, as well as Bootstrap's Card and Badge components. In addition, there are classes o2h-* attached such as o2h-data-type to allow some customized styling.

This is what worked for me:

<html>
<head>
  ...
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
  <style>
    .card {
      margin-bottom: 1rem;
    }
    .h2, h2 {
      margin-top: 1rem;
    }
    .h4, h4 {
      margin-top: .5rem;
    }
    .card .card-body .h4, .card .card-body h4 {
      border-top: 1px solid #eee;
      margin-top: 1rem;
      padding-top: 1rem;
    }
    .card .card-body .h5, .card .card-body h5 {
      margin-top: 1rem;
    }
    .o2h-description p {
      color: grey;
    }
    .card .card-body .o2h-description p {
      margin-bottom: 0;
    }
    .card .card-body .o2h-example pre {
      background-color: #eee;
    }
  </style>
</head>
<body>
  <div class="container">
    <!-- include api html here -->
  </div>
</body>
</html>

Keywords

FAQs

Package last updated on 06 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc