Gathering detailed insights and metrics for swagger-express-middleware
Gathering detailed insights and metrics for swagger-express-middleware
Gathering detailed insights and metrics for swagger-express-middleware
Gathering detailed insights and metrics for swagger-express-middleware
@apidevtools/swagger-express-middleware
Swagger middleware and mocks for Express
@types/swagger-express-middleware
TypeScript definitions for swagger-express-middleware
swagger-express-mw
Swagger loader and middleware for express
redoc-express
Express Middleware for OpenAPI/Swagger-generated API Reference Documentation
Swagger 2.0 middlware and mocks for Express.js
npm install swagger-express-middleware
Typescript
Module System
Min. Node Version
Node Version
NPM Version
29.6
Supply Chain
80.5
Quality
77.3
Maintenance
50
Vulnerability
98.9
License
JavaScript (100%)
Total Downloads
14,446,127
Last Day
1,283
Last Week
6,765
Last Month
41,094
Last Year
497,237
573 Stars
335 Commits
199 Forks
21 Watching
3 Branches
15 Contributors
Minified
Minified + Gzipped
Latest Version
4.0.2
Package Id
swagger-express-middleware@4.0.2
Size
4.94 kB
NPM Version
6.14.6
Node Version
10.22.0
Publised On
01 Aug 2020
Cumulative downloads
Total Downloads
Last day
-1.9%
1,283
Compared to previous day
Last week
-14.5%
6,765
Compared to previous week
Last month
-16.3%
41,094
Compared to previous month
Last year
37.8%
497,237
Compared to previous year
1
Supports Swagger 2.0 specs in JSON or YAML
Swagger Express Middleware uses Swagger-Parser to parse, validate, and dereference Swagger files. You can even split your spec into multiple different files using $ref
pointers.
Thoroughly tested
Over 1,000 unit tests and integration tests with 100% code coverage. Tested on over 1,500 real-world APIs from Google, Microsoft, Facebook, Spotify, etc. All tests are run on Mac, Linux, and Windows using all LTS versions of Node.
Mock middleware
Fully-functional mock implementations for every operation in your API, including data persistence, all with zero code! This is a great way to test-drive your API as you write it, or for quick demos and POCs. You can even extend the mock middleware with your own logic and data to fill in any gaps.
Metadata middleware
Annotates each request with all the relevant information from the Swagger definition. The path, the operation, the parameters, the security requirements - they're all easily accessible at req.swagger
.
Parse Request middleware
Parses incoming requests and converts everything into the correct data types, according to your Swagger API definition.
Validate Request middleware
Ensures that every request complies with your Swagger API definition, or returns the appropriate HTTP error codes if needed. Of course, you can catch any validation errors and handle them however you want.
CORS middleware
Adds the appropriate CORS headers to each request and automatically responds to CORS preflight requests, all in compliance with your Swagger API definition.
Files middleware
Serves the Swagger API file(s) in JSON or YAML format so they can be used with front-end tools like Swagger UI, Swagger Editor, and Postman.
Install using npm.
1npm install @apidevtools/swagger-express-middleware
Then use it in your Node.js script like this:
1const express = require('express'); 2const createMiddleware = require('@apidevtools/swagger-express-middleware'); 3 4let app = express(); 5 6createMiddleware('PetStore.yaml', app, function(err, middleware) { 7 // Add all the Swagger Express Middleware, or just the ones you need. 8 // NOTE: Some of these accept optional options (omitted here for brevity) 9 app.use( 10 middleware.metadata(), 11 middleware.CORS(), 12 middleware.files(), 13 middleware.parseRequest(), 14 middleware.validateRequest(), 15 middleware.mock() 16 ); 17 18 app.listen(8000, function() { 19 console.log('The PetStore sample is now running at http://localhost:8000'); 20 }); 21});
Swagger Express Middleware comes two samples that use the Swagger Pet Store API.
This sample demonstrates the most simplistic usage of Swagger Express Middleware. It simply creates a new Express Application and adds all of the Swagger middleware without changing any options, and without adding any custom middleware.
This sample demonstrates a few more advanced features of Swagger Express Middleware, such as setting a few options, initializing the mock data store, and adding custom middleware logic.
I welcome any contributions, enhancements, and bug-fixes. Open an issue on GitHub and submit a pull request.
To build/test the project locally on your computer:
Clone this repo
git clone https://github.com/APIDevTools/swagger-express-middleware.git
Install dependencies
npm install
Run the tests
npm test
Run the sample app
npm start
Swagger Express Middleware is 100% free and open-source, under the MIT license. Use it however you want.
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
Thanks to these awesome companies for their support of Open Source developers ❤
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 2/16 approved changesets -- score normalized to 1
Reason
project is archived
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
40 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-23
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