83

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?

StuBob
  • 1,192
  • 1
  • 8
  • 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
  • You can use postman2openapi on the web: https://kevinswiber.github.io/postman2openapi/ – Arlemi Apr 07 '21 at 14:22

3 Answers3

92

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.

Helen
  • 58,317
  • 8
  • 161
  • 218
MikeRalphson
  • 1,751
  • 1
  • 12
  • 13
16

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,192
  • 1
  • 8
  • 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
  • 344
  • 2
  • 5