Code Monkey home page Code Monkey logo

swagger2postman's Introduction

swagger2postman

Create a Postman collection from Swagger documentation

##Motivation

Swagger UI provides a nice way to interact with an API documented by the Swagger specification.
But if you're working with an identical API across multiple environments, or you want to test edge cases that Swagger UI doesn't support (like omitting a required query parameter), Swagger UI comes up a bit short.

Postman to the rescue! Using Postman you can define variables for multiple environments and have more control over request generation. This library takes Swagger documentation served in JSON and converts it into a JSON collection which can be imported directly into Postman.

##Demo

Try out an online version at http://app.josephpconley.com/swagger2postman

##Command line

sbt run <host> <collectionName> [<headerKey=headerValue> ... ]

Prints out json and writes json file to current directory.

##Multiple environments

To take advantage of multi-environment testing, I would first run swagger2postman against a hosted Swagger doc.
Then I do a simple Find/Replace, replacing the target host with a handlebars variable like {{host}}. Then I create environments in Postman that define a value for the config key host.
Toggling these environments with your imported collection will let you seamlessly test your API in different environments.

You can also use environment variables for authentication. If your API uses a header for authentication, then pass a headerKey={{headerValue}} so that all endpoints get a global authentication header with an environment-dependent value.

##Next Steps This currently supports Swagger 1.2. There appears to be Swagger 2.0 import functionality in the current version of Postman, though I haven't gotten it to work, so if there's enough demand for a Swagger 2.0 version, let me know in the issues section (or add it yourself!)

swagger2postman's People

Contributors

josephpconley avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.