Postman collections to swagger
npm install postman-2-swaggerWe like to use postman, but often we get asked for swagger docs. There doesn't seem to be any open source postman v2.0.0 => swagger/openApi tools. Maybe a commercial reason, here is one for you.
``js
import postmanToSwagger from 'postman-to-swagger';
const convertAndSave = postmanJson => {
// This returns the actual swagger v2.0 spec as a json
const swaggerJson = postmanToSwagger(postmanJson);
// Example if you want to save it somewhere
fs.writeFile(
'../_docs/swagger.json',
JSON.stringify(swaggerJson, null, 2),
'utf8'
);
};
`
With swagger-ui-express
`js
import postmanToSwagger from 'postman-to-swagger';
import swaggerUi from 'swagger-ui-express';
import mockCollection from './mockCollection.json';
swagger.get('/swagger', swaggerUi.setup(postmanToSwagger(mockCollection)));
// Static stuff
swagger.use('/', swaggerUi.serve, (req, res) => res.status(404).end());
`
- name, description, version
- routes, folders
- examples, status codes
`bash`Build this lib
npm run buildGo into demo folder and install
npm installThen run the demo
npm run watch
- Apimatic has this models thing that is kind of useful, maybe we can also do that.lodash/fp
- Use , lodash/fp/flow` to slim down module size
- api-flow - broken, but maybe inspiring.
- postman2swagger2 - Doesn't support postman v2