Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Puer | 1,221 | 43 | 10 | 3 years ago | 27 | June 24, 2020 | 30 | JavaScript | ||
more than a live-reload server, built for efficient front-end development | ||||||||||
Dyson | 836 | 43 | 13 | 4 months ago | 66 | June 08, 2021 | 8 | JavaScript | ||
Node server for dynamic, fake JSON. | ||||||||||
Swagger Express Middleware | 548 | 117 | 44 | 2 years ago | 51 | August 01, 2020 | 97 | mit | JavaScript | |
Swagger 2.0 middlware and mocks for Express.js | ||||||||||
Openapi Backend | 448 | 5 | 19 | 3 days ago | 108 | August 27, 2022 | 70 | mit | TypeScript | |
Build, Validate, Route, Authenticate and Mock using OpenAPI | ||||||||||
Vue Fullstack | 293 | 5 years ago | 3 | mit | JavaScript | |||||
vue fullstack template | ||||||||||
Elm | 193 | 4 years ago | Vue | |||||||
🐇 vue^2.5.2 + express + stylus elm demo | ||||||||||
Gulp Server Io | 154 | 5 years ago | mit | JavaScript | ||||||
Standalone / gulp (stream) / delivery server setup with Proxy options remote debugger and more | ||||||||||
Main | 126 | 3 | 5 | 2 months ago | 46 | September 01, 2022 | 52 | apache-2.0 | JavaScript | |
Mocks Server monorepo | ||||||||||
Typeorm Mock Unit Testing Example | 97 | 8 months ago | n,ull | mit | TypeScript | |||||
Example how to mock TypeORM database connection for your blazing unit-tests with Mocha and Jest | ||||||||||
Mock Express Request Response | 62 | 3 months ago | mit | JavaScript | ||||||
Mock/stub the Express request/response objects using Jest or sinon |
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.
npm install @apidevtools/swagger-express-middleware
Then use it in your Node.js script like this:
const express = require('express');
const createMiddleware = require('@apidevtools/swagger-express-middleware');
let app = express();
createMiddleware('PetStore.yaml', app, function(err, middleware) {
// Add all the Swagger Express Middleware, or just the ones you need.
// NOTE: Some of these accept optional options (omitted here for brevity)
app.use(
middleware.metadata(),
middleware.CORS(),
middleware.files(),
middleware.parseRequest(),
middleware.validateRequest(),
middleware.mock()
);
app.listen(8000, function() {
console.log('The PetStore sample is now running at http://localhost:8000');
});
});
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 youll be creating employment for local families and restoring wildlife habitats.
Thanks to these awesome companies for their support of Open Source developers