All Projects → postmanlabs → Openapi To Postman

postmanlabs / Openapi To Postman

Licence: apache-2.0
Plugin for converting OpenAPI 3.0 specs to the Postman Collection (v2) format

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Openapi To Postman

Prism
Turn any OpenAPI2/3 and Postman Collection file into an API server with mocking, transformations and validations.
Stars: ✭ 2,484 (+580.55%)
Mutual labels:  openapi, openapi3, postman-collection
shipengine-openapi
The official OpenAPI 3.0 definitions for ShipEngine™
Stars: ✭ 13 (-96.44%)
Mutual labels:  openapi, openapi3
Php Openapi
Read and write OpenAPI yaml/json files and make the content accessible in PHP objects.
Stars: ✭ 268 (-26.58%)
Mutual labels:  openapi, openapi3
sbt-openapi-schema
Generate schema sources for Scala, Java and Elm from an openapi 3.0 spec.
Stars: ✭ 12 (-96.71%)
Mutual labels:  openapi, openapi3
openapi
OpenAPI (fka Swagger) spec renderer for Sphinx.
Stars: ✭ 78 (-78.63%)
Mutual labels:  openapi, openapi3
apiflask
A lightweight Python web API framework.
Stars: ✭ 442 (+21.1%)
Mutual labels:  openapi, openapi3
thema
A CUE-based framework for portable, evolvable schema
Stars: ✭ 41 (-88.77%)
Mutual labels:  openapi, openapi3
nexmo-oas-renderer
Render your API references, Nexmo-style!
Stars: ✭ 40 (-89.04%)
Mutual labels:  openapi, openapi3
openapi-schemas
JSON Schemas for every version of the OpenAPI Specification
Stars: ✭ 22 (-93.97%)
Mutual labels:  openapi, openapi3
Openapi Generator Cli
A node package wrapper for https://github.com/OpenAPITools/openapi-generator
Stars: ✭ 305 (-16.44%)
Mutual labels:  openapi, openapi3
go-openapi
OpenAPI Specification (OAS) 3.0 implementation for Go
Stars: ✭ 38 (-89.59%)
Mutual labels:  openapi, openapi3
Generator Express No Stress Typescript
🚄 A Yeoman generator for Express.js based 12-factor apps and apis using Typescript
Stars: ✭ 297 (-18.63%)
Mutual labels:  openapi, openapi3
light-rest-4j
A RESTful framework built on top of light-4j with both Swagger 2.0 and OpenAPI 3.0 supports
Stars: ✭ 113 (-69.04%)
Mutual labels:  openapi, openapi3
openapi-lint-vscode
OpenAPI 2.0/3.0.x intellisense, validator, linter, converter and resolver extension for Visual Studio Code
Stars: ✭ 47 (-87.12%)
Mutual labels:  openapi, openapi3
php-json-schema-model-generator
Creates (immutable) PHP model classes from JSON-Schema files including all validation rules as PHP code
Stars: ✭ 36 (-90.14%)
Mutual labels:  openapi, openapi3
openapi-schema-validator
OpenAPI schema validator for Python
Stars: ✭ 35 (-90.41%)
Mutual labels:  openapi, openapi3
Safrs
SqlAlchemy Flask-Restful Swagger Json:API OpenAPI
Stars: ✭ 255 (-30.14%)
Mutual labels:  openapi, openapi3
KaiZen-OpenApi-Parser
High-performance Parser, Validator, and Java Object Model for OpenAPI 3.x
Stars: ✭ 119 (-67.4%)
Mutual labels:  openapi, openapi3
swagger-petstore
petstore.swagger.io
Stars: ✭ 84 (-76.99%)
Mutual labels:  openapi, openapi3
fastify-openapi-glue
A plugin for Fastify to autogenerate a configuration based on a OpenApi(v2/v3) specification.
Stars: ✭ 94 (-74.25%)
Mutual labels:  openapi, openapi3

postman icon

Supercharge your API workflow.
Modern software is built on APIs. Postman helps you develop APIs faster.

OpenAPI 3.0 to Postman Collection v2.1.0 Converter

Build Status

Contents

  1. Getting Started
  2. Using the converter as a NodeJS module
    1. Convert Function
    2. Options
    3. ConversionResult
    4. Sample usage
    5. Validate function
  3. Command Line Interface
    1. Options
    2. Usage
  4. Conversion Schema

Getting Started

To use the converter as a Node module, you need to have a copy of the NodeJS runtime. The easiest way to do this is through npm. If you have NodeJS installed you have npm installed as well.

$ npm install openapi-to-postmanv2

Using the converter as a NodeJS module

In order to use the convert in your node application, you need to import the package using require.

var Converter = require('openapi-to-postmanv2')

The converter provides the following functions:

Convert

The convert function takes in your OpenAPI specification ( YAML / JSON ) and converts it to a Postman collection.

Signature: convert (data, options, callback);

data:

{ type: 'file', data: 'filepath' }
OR
{ type: 'string', data: '<entire OpenAPI string - JSON or YAML>' }
OR
{ type: 'json', data: OpenAPI-JS-object }

options:

{
  schemaFaker: true,
  requestNameSource: 'fallback',
  indentCharacter: ' '
}
/*
All three properties are optional. Check the options section below for possible values for each option.
*/

callback:

function (err, result) {
  /*
  result = {
    result: true,
    output: [
      {
        type: 'collection',
        data: {..collection object..}
      }
    ]
  }
  */
}

Options:

Check out complete list of options and their usage at OPTIONS.md

ConversionResult

  • result - Flag responsible for providing a status whether the conversion was successful or not

  • reason - Provides the reason for an unsuccessful conversion, defined only if result: false

  • output - Contains an array of Postman objects, each one with a type and data. The only type currently supported is collection.

Sample Usage:

var fs = require('fs'),

Converter = require('openapi-to-postmanv2'),
openapiData = fs.readFileSync('sample-spec.yaml', {encoding: 'UTF8'});

Converter.convert({ type: 'string', data: openapiData },
  {}, (err, conversionResult) => {
    if (!conversionResult.result) {
      console.log('Could not convert', conversionResult.reason);
    }
    else {
      console.log('The collection object is: ', conversionResult.output[0].data);
    }
  }
);

Validate Function

The validate function is meant to ensure that the data that is being passed to the convert function is a valid JSON object or a valid (YAML/JSON) string.

The validate function is synchronous and returns a status object which conforms to the following schema

Validation object schema

{
  type: 'object',
  properties: {
    result: { type: 'boolean'},
    reason: { type: 'string' }
  },
  required: ['result']
}
Validation object explanation
  • result - true if the data looks like OpenAPI and can be passed to the convert function

  • reason - Provides a reason for an unsuccessful validation of the specification

Command Line Interface

The converter can be used as a CLI tool as well. The following command line options are available.

openapi2postmanv2 [options]

Options

  • -v, --version
    Specifies the version of the converter

  • -s <source>, --spec <source>
    Used to specify the OpenAPI specification (file path) which is to be converted

  • -o <destination>, --output <destination>
    Used to specify the destination file in which the collection is to be written

  • -t, --test
    Used to test the collection with an in-built sample specification

  • -p, --pretty
    Used to pretty print the collection object while writing to a file

  • -O, --options Used to supply options to the converter, for complete options details see here

  • -c, --options-config
    Used to supply options to the converter through config file, for complete options details see here

  • -h, --help
    Specifies all the options along with a few usage examples on the terminal

Usage

Sample usage examples of the converter CLI

  • Takes a specification (spec.yaml) as an input and writes to a file (collection.json) with pretty printing and using provided options
$ openapi2postmanv2 -s spec.yaml -o collection.json -p -O folderStrategy=Tags,includeAuthInfoInExample=false
  • Takes a specification (spec.yaml) as an input and writes to a file (collection.json) with pretty printing and using provided options via config file
$ openapi2postmanv2 -s spec.yaml -o collection.json -p  -c ./examples/cli-options-config.json
  • Testing the converter
$ openapi2postmanv2 --test

Conversion Schema

postman openapi options examples
collectionName info.title -
description info.description + info.contact -
collectionVariables server.variables + pathVariables -
folderName paths.path -
requestName operationItem(method).operationId default(operationId)-(requestName)enum['operationId','summary','url']
request.method path.method -
request.headers parameter (in = header) - link
request.body operationItem(method).requestBody -
request.url.raw server.url (path level server >> openapi server) + path -
request.url.variables parameter (in = path) - link
request.url.params parameter (in = query) - {"key": param.name, "value": link}
api_key in (query or header) components.securitySchemes.api_key -
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].