Socket
Book a DemoInstallSign in
Socket

cds-swagger-ui-express

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cds-swagger-ui-express

Swagger UI for CAP Services

0.2.0
Source
npmnpm
Version published
Weekly downloads
4.8K
-28.47%
Maintainers
1
Weekly downloads
 
Created
Source

cds-swagger-ui-express

An express middleware to serve OpenAPI definitions for CAP services in Swagger UI. Builds on top of swagger-ui-express.

Preview

Installation

In your project, execute

npm install --save-dev cds-swagger-ui-express

Usage

Have this in your server.js:

const cds = require ('@sap/cds')
module.exports = cds.server

if (process.env.NODE_ENV !== 'production') {
  const cds_swagger = require ('cds-swagger-ui-express')
  cds.on ('bootstrap', app => app.use (cds_swagger()) )
}

Swagger UI is then served on /$api-docs/<service-path>, like http://localhost:4004/$api-docs/browse/

Configuration

Call cds_swagger ({...}) with the following object:

{
  "basePath": "/$api-docs", // the root path to mount the middleware on
  "diagram": "true" // whether to render the YUML diagram
}

Notes

If you call cds.serve on your own in your server.js, make sure to install this middleware before, as it relies on CDS' serving events.

Keywords

cap

FAQs

Package last updated on 12 Jul 2021

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.