Fork from swagger-express-middleware
The main goal of the fork is to use the latest multer
package (multer 1.x) for compatibility with the multer-s3
package that is supposed to be used to upload files to AWS S3.
Install using npm.
npm install swagger-express-middleware
Then use it in your Node.js script like this:
const express = require('express');
const createMiddleware = require('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 is 100% free and open-source, under the MIT license. Use it however you want.