swagger-ux

1.0.3 • Public • Published

Swagger-UX

swagger-ux allows restify/express to serve the swagger-ui/redoc without hosting expect swagger document and index file.

What is Swagger-UI?

Swagger UI allows anyone — be it your development team or your end consumers — to visualize and interact with the API’s resources without having any of the implementation logic in place. It’s automatically generated from your Swagger specification, with the visual documentation making it easy for back-end implementation and client-side consumption.

What is ReDoc?

Redoc is OpenAPI/Swagger-generated API Reference Documentation and it provides a responsive three-panel design with menu/scrolling synchronization.

Install

$ npm install --save swagger-ux

Usage

Setup

    const SwaggerUX = require('swagger-ux');
    const SwaggerDocumentPath = __dirname + "./swagger.yaml";
    const options = {
        "documentPath": SwaggerDocumentPath
    }
    SwaggerUX.route(server,options); 

Options

key value required notes
documentPath or documentUrl absolute path of the document file or document url` true *filePath deprecated
title string false html title
defaultUI enum( swagger,redoc ) false default ui is swagger
routePath document url route path on server false default path /api-docs
auth middleware function like authentication function false must be instanceof Function
script valid javascript false Example:
style valid html style tag false

Open http://<app_host_url>:<app_port>/api-docs in your browser to view the documentation.

Documentation UI

By default, swagger-ux will serve swagger-ui (3.6.1). You can switch the user interface of the documentation based on query parameter from the url

  • http://<app_host_url>:/api-docs?ui=redoc
  • http://<app_host_url>:/api-docs?ui=swagger

Requirement

Package Sidebar

Install

npm i swagger-ux

Weekly Downloads

57

Version

1.0.3

License

MIT

Last publish

Collaborators

  • anbuksv