1.0.3 • Published 6 years ago

swagger-ux v1.0.3

Weekly downloads
17
License
MIT
Repository
github
Last release
6 years ago

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

keyvaluerequirednotes
documentPath or documentUrlabsolute path of the document file or document url` | true | *filePath deprecated
titlestringfalsehtml title
defaultUIenum( swagger,redoc )falsedefault ui is swagger
routePathdocument url route path on serverfalsedefault path /api-docs
authmiddleware function like authentication functionfalsemust be instanceof Function
scriptvalid javascriptfalseExample: alert('hello world');
stylevalid html style tagfalse

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