You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

postman-2-swagger

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postman-2-swagger

Postman collections to swagger

0.5.0
latest
npmnpm
Version published
Weekly downloads
993
-5.34%
Maintainers
1
Weekly downloads
 
Created
Source

Postman to swagger

coverage

We 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.

Usage

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

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());

What it converts

  • name, description, version
  • routes, folders
  • examples, status codes

Demo

# Build this lib
npm run build
# Go into demo folder and install
npm install
# Then run the demo
npm run watch

Future improvement

  • Apimatic has this models thing that is kind of useful, maybe we can also do that.
  • Use lodash/fp, lodash/fp/flow to slim down module size

Repos to watch

  • api-flow - broken, but maybe inspiring.
  • postman2swagger2 - Doesn't support postman v2

Keywords

postman

FAQs

Package last updated on 18 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts