Skip to main content

openapi cli tool

Project description


Build Status


OpenAPI (Swagger 3.x) CLI Tool.

  • Supports multiple file extensions (json|yaml|yml).
  • Can list up defined API paths.
  • Display an API specification which is resolved ($ref).
  • Bundle multi-file into one (output to json|yaml|html).
  • OAS interactive scaffolding.


Python 2.7, 3.4 <=.


With pip:

$ pip install openapi-cli-tool

Clone the repository and execute the Python installation command on your machine.

$ pip -r requirements.txt install
$ python install

Then openapi-cli-tool command is installed.


$ openapi-cli-tool --help
Usage: openapi-cli-tool [OPTIONS] COMMAND [ARGS]...

  --help  Show this message and exit.

  bundle    Bundle multiple files into one.
  list      List up API paths in a file or directory.
  resolve   Display `$ref` resolved API specification.
  scaffold  Interactively create a simple OpenAPI Specification.


Bundle multi-file specifications into one, regardless of file extension (json|yaml|yml).

$ openapi-cli-tool bundle --help
Usage: openapi-cli-tool bundle [OPTIONS] FILE_PATHS

  Bundle multiple files into one.

  -f, --file TEXT  Load common objects such as info and servers from a
                   specific file. Default is a file which is the top of list
                   command result.
  -t, --type TEXT  Export data type. {json|yaml|html}  [default: json]
  --help           Show this message and exit.


$ openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html

In the html file, an unpkg version of swagger-ui is embedded. Rendered screenshot below:



List up API paths from a file/directory regardless of the file extension (json|yaml|yml).

$ openapi-cli-tool list `find ./spec`

Method    Path       File
--------  ---------  ------------------------------------------
PUT       /avatar    ./tests/resources/spec/sample.yml
GET       /follwers  ./tests/resources/spec/folder1/sample2.yaml
POST      /follwers  ./tests/resources/spec/folder1/sample2.yaml
PUT       /follwers  ./tests/resources/spec/folder1/sample2.yaml
POST      /pets      ./tests/resources/spec/sample.yml
GET       /posts     ./tests/resources/spec/folder1/sample.json
POST      /posts     ./tests/resources/spec/folder1/sample.json
GET       /users     ./tests/resources/spec/folder1/sample.json
POST      /users     ./tests/resources/spec/folder1/sample.json


Display an API specification which is resolved from a multi-file API specification via $ref pointers.

Usage: openapi-cli-tool resolve [OPTIONS] METHOD PATH FILE_PATHS

  Display `$ref` resolved API specification.

  -t, --type TEXT  Export data type. {json|yaml}  [default: json]
  --help           Show this message and exit.


$ openapi-cli-tool resolve post /cats `find ./tests/resources/spec`


Interactively input information of your API.
A simple OpenAPI Specification is generated from your prompt.

$ openapi-cli-tool scaffold

Please enter title [""]: sample
Please enter version [v1.0]:
Please enter license [Apache 2.0]:
Please enter server url []:
Please enter path [/]: /example
Please enter method for /example [get|post|put|delete|head|option|trace]: get
Please enter description for get /example [""]: sample get endpoint
Please enter response code for get /example [200]:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openapi-cli-tool-0.3.0.tar.gz (7.7 kB view hashes)

Uploaded source

Built Distributions

openapi_cli_tool-0.3.0-py3-none-any.whl (11.1 kB view hashes)

Uploaded py3

openapi_cli_tool-0.3.0-py2-none-any.whl (11.1 kB view hashes)

Uploaded py2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page