Installations
npm install swagger-ui-koa
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>= v0.10.32
Node Version
7.8.0
NPM Version
4.2.0
Score
78.7
Supply Chain
99.1
Quality
74.8
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
HTML (75.49%)
JavaScript (24.51%)
Developer
Darmikon
Download Statistics
Total Downloads
271,644
Last Day
233
Last Week
742
Last Month
3,477
Last Year
61,498
GitHub Statistics
8 Stars
1 Commits
5 Forks
2 Watching
1 Branches
1 Contributors
Bundle Size
1.14 kB
Minified
641.00 B
Minified + Gzipped
Package Meta Information
Latest Version
0.0.1
Package Id
swagger-ui-koa@0.0.1
Size
475.30 kB
NPM Version
4.2.0
Node Version
7.8.0
Total Downloads
Cumulative downloads
Total Downloads
271,644
Last day
9.9%
233
Compared to previous day
Last week
-32.6%
742
Compared to previous week
Last month
0.5%
3,477
Compared to previous month
Last year
-28.1%
61,498
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
1
Swagger UI Koa 2
Forked from swagger-ui-express
Adds middleware to your koa app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.
Updated to Swagger 3.0.17
Usage
In app's package.json
"swagger-ui-koa": "latest" // or desired version
Setup swagger-app-wrapper.js
1import swaggerUi from 'swagger-ui-koa'; 2import swaggerJSDoc from 'swagger-jsdoc'; 3import convert from 'koa-convert'; 4import mount from 'koa-mount'; 5//import swaggerDocument from './swagger.json'; //also can be used 6 7export default function (app) { 8 //without jsdoc from swagger.json 9 //app.use(swaggerUi.serve); //serve swagger static files 10 //app.use(convert(mount('/swagger', swaggerUi.setup(swaggerDocument)))); //mount endpoint for access 11 12 //with jsdoc 13 const options = { 14 swaggerDefinition: { 15 info: { 16 title: 'API', // Title (required) 17 version: '2.0.0', // Version (required) 18 }, 19 }, 20 apis: [ 21 './src/module/swagger/swagger.yaml', 22 './src/routes/*.js', // Path to the API docs from root 23 './src/module/swagger/parameters.yaml' 24 ], 25 }; 26 // Initialize swagger-jsdoc -> returns validated swagger spec in json format 27 const swaggerSpec = swaggerJSDoc(options); 28 app.use(swaggerUi.serve); //serve swagger static files 29 app.use(convert(mount('/swagger', swaggerUi.setup(swaggerSpec)))); //mount endpoint for access 30} 31
Open http://<app_host>
:<app_port>
/swagger in your browser to view the documentation.
swagger-jsdoc
Swagger Explorer
By default the Swagger Explorer bar is hidden, to display it pass true as the second parameter to the setup function:
1const express = require('express'); 2const app = express(); 3const swaggerUi = require('swagger-ui-express'); 4const swaggerDocument = require('./swagger.json'); 5 6var showExplorer = true; 7 ... 8 swaggerUi.setup(swaggerDocument, showExplorer) 9 ...
Custom swagger options
To pass custom options e.g. validatorUrl, to the SwaggerUi client pass an object as the third parameter:
1 2var showExplorer = true; 3var options = { 4 validatorUrl : null 5}; 6... 7swaggerUi.setup(swaggerDocument, showExplorer, options)); 8...
Custom CSS styles
To customize the style of the swagger page, you can pass custom CSS as the fourth parameter.
E.g. to hide the swagger header:
1var showExplorer = false; 2var options = {}; 3var customCss = '#header { display: none }'; 4 5... 6swaggerUi.setup(swaggerDocument, showExplorer, options, customCss)); 7...
Requirements
- Koa 2
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/1 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.6
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More