111

I am developing a REST API. during development I have used postman (chrome extension) to use and document my API. It is a wonderful tool and I have most of my API endpoints in it. However, as we near release I would like to document this API in swagger, how would I do that? Is there a way that I can generate swagger based off of the postman export?

Helen
  • 87,344
  • 17
  • 243
  • 314
StuBob
  • 1,490
  • 2
  • 10
  • 13
  • For C#/DotNet, see these two: 1.[]c# - How to generate JSON Postman Collections from a WebApi2 project using WebApi HelpPages that are suitable for import - Stack Overflow ; ; stackoverflow.com/questions/23158379/ ; ; ; 2.[]; ; X.Introducing the Azure API Apps Tools for Visual Studio 2013 - The Visual Studio Blog - Site Home - MSDN Blogs ; ; http://blogs.msdn.com/b/visualstudio/archive/2015/03/24/introducing-the-azure-api-apps-tools-for-visual-studio-2013.aspx – AnneTheAgile Dec 23 '15 at 03:46
  • 4
    You can use postman2openapi on the web: https://kevinswiber.github.io/postman2openapi/ – Arlemi Apr 07 '21 at 14:22
  • https://metamug.com/util/postman-to-swagger/ is most updated tool. – Sorter Sep 20 '21 at 12:04
  • you can use postman to swagger online tool https://www.workversatile.com/postman-to-swagger – Arshad Shaikh Aug 16 '22 at 11:44

3 Answers3

110

As of 2022 my recommendation is the excellent Rust/Wasm tool from Kevin Swiber, which is available online, as a Rust crate and as an npm module. https://kevinswiber.github.io/postman2openapi/

APIMatic API Transformer can process a Postman collection (v1 or v2) as an input format and produce Swagger 1.2 or 2.0, and now OpenAPI 3.0.0 as output.

It has its own API and a Web front-end, and also a command-line version.

MikeRalphson
  • 2,247
  • 2
  • 15
  • 16
  • 13
    Note that the site requires an account to be created to use. – ryanwebjackson Mar 01 '19 at 19:31
  • now supports swagger 2.1 – OzBob Oct 29 '19 at 04:02
  • This works like a charm when I tried to convert my postman V2.1 json to swagger 2.0. But they ask you to sign up first. – Sathish Nov 22 '19 at 10:30
  • I have signed up and they have provided me a 14 days trial period, not sure if I would be able to convert the Postman collection to Swagger post the trial period is over. – Rito Jan 25 '21 at 05:22
  • 2
    Why not try a free online converter like any other converter. All it takes is some javascript https://metamug.com/util/postman-to-swagger/ – Sorter Sep 20 '21 at 12:06
  • 1
    this doesn't work :) – programmar Oct 21 '21 at 10:12
  • I now recommend https://github.com/kevinswiber/postman2openapi – MikeRalphson Mar 13 '23 at 12:16
  • Maybe I'm missing something, but even on the github.io page there's a big link saying "Fork Me" so there's no need to signup for anything. Both the io and com links show how to download the binaries and run them locally without needing to create an account. Are you prompted from the command line??? – Bob Ramsey Jun 12 '23 at 15:21
18

Someone posted this link (and deleted it?): http://restunited.com/

It accepts postman JSON and converts it to swagger. This seems to be what I was looking for.

StuBob
  • 1,490
  • 2
  • 10
  • 13
14

You can use https://github.com/stoplightio/api-spec-converter with code

var transformer = require('api-spec-transformer');

var postmanToSwagger = new transformer.Converter(transformer.Formats.POSTMAN, transformer.Formats.SWAGGER);

postmanToSwagger.loadFile('/path/to/your.json.postman_collection', function(err) {
  if (err) {
    console.log(err.stack);
    return;
  }

  postmanToSwagger.convert('yaml')
    .then(function(convertedData) {
      // convertedData is swagger YAML string
      console.log(convertedData);
    })
    .catch(function(err){
      console.log(err);
    });
});
plotnik
  • 372
  • 2
  • 5