Skip to content

Customizable Converter for OpenAPI 3.0 to Postman 2.1 Collections

License

Notifications You must be signed in to change notification settings

weikangchia/op-converter

Repository files navigation

OpenAPI 3.0 to Postman 2.1 Collections Converter

op-converter is a customizable converter for OpenAPI 3.0 to Postman 2.1 Collections.

Getting Started

Pre-requisites

  • Install node
  • Install op-converter
    npm install -g op-converter
    

Usage

USAGE:
    op-converter

OPTIONS:
    - f, --openApiFile=openApiFile    path to your OpenAPI 3.0 JSON file
    - h, --help                       show CLI help
    - n, --name=name                  name for your postman collection
    --baseUrl=baseUrl                 base url
    --config=config                   custom config file name (default is config.json)

Examples

op-converter -f ./openapi.json -n "My Collection" --baseUrl="http://localhost" > postman.json

Configuration Options

By default op-converter reads all configurable options from config.json at the following location

Unix: ~/.config/op-converter
Windows: %LOCALAPPDATA%\gitcg

Below are the available configurable options.

path

Name Value
type object
mandatory false

Example

{
  "path": {}
}

enableReplacePrefix

Name Value
type boolean
parent path
mandatory false
mandatory siblings replacePrefix, replacePrefixWith

Example

{
  "path": {
    "enableReplacePrefix": true,
    "replacePrefix": "/v1",
    "replacePrefixWith": ""
  }
}

replacePrefix

Name Value
type string
parent path
mandatory false
mandatory siblings enableReplacePrefix, replacePrefixWith

Example

{
  "path": {
    "enableReplacePrefix": true,
    "replacePrefix": "/v1",
    "replacePrefixWith": ""
  }
}

replacePrefixWith

Name Value
type string
parent path
mandatory false
mandatory siblings enableReplacePrefix, replacePrefix

Example

{
  "path": {
    "enableReplacePrefix": true,
    "replacePrefix": "/v1",
    "replacePrefixWith": ""
  }
}

auth

Postman Auth field

Name Value
type object
mandatory false

Example

{
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{CURRENT_ACCESS_TOKEN}}",
        "type": "string"
      }
    ]
  }
}

events

Postman event field

Name Value
type array
mandatory false

Example

{
  "events": [
    {
      "listen": "test",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ]
}

License

Distributed under the MIT License. See LICENSE for more information.

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

Contact

Wei Kang - weikangchia[@]gmail.com