Skip to content

Latest commit

 

History

History
97 lines (71 loc) · 3.89 KB

File metadata and controls

97 lines (71 loc) · 3.89 KB

OpenAPI Command Line Tool

CI License npm version npm downloads npm type definitions Buy me a coffee

openapicmd - The CLI for all things OpenAPI and Swagger

Battle-tested in production. See who uses openapi-stack →

Install

npm install -g openapicmd
openapi help

Features

  • Parse local and remote JSON/YAML OpenAPI definition files
  • Generate TypeScript types from OpenAPI definitions
  • Emit client-oriented types for openapi-client-axios
  • Optionally strip metadata and prune unreferenced components before generation

Commands

openapi help [COMMAND]

Display help for openapi.

USAGE
  $ openapi help [COMMAND...] [-n]

ARGUMENTS
  [COMMAND...]  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for openapi.

See code: @oclif/plugin-help

openapi typegen [DEFINITION]

Generate types from openapi definition

USAGE
  $ openapi typegen [DEFINITION] [-h] [-D] [-B] [-R /] [-H <value>...] [-V] [-S http://localhost:9000...] [-I
    {"info":{"version":"1.0.0"}}...] [-E x-internal] [-C default|all|openapi_client_axios] [-U] [-b <value>] [-A]

ARGUMENTS
  [DEFINITION]  input definition file

FLAGS
  -A, --[no-]type-aliases                       Generate module level type aliases for schema components defined in spec
  -B, --bundle                                  resolve remote $ref pointers
  -C, --strip=default|all|openapi_client_axios  Strip optional metadata such as examples and descriptions from
                                                definition
  -D, --dereference                             resolve $ref pointers
  -E, --exclude-ext=x-internal                  Specify an openapi extension to exclude parts of the spec
  -H, --header=<value>...                       add request headers when calling remote urls
  -I, --inject={"info":{"version":"1.0.0"}}...  inject JSON to definition with deep merge
  -R, --root=/                                  override API root path
  -S, --server=http://localhost:9000...         override servers definition
  -U, --[no-]remove-unreferenced                Remove unreferenced components, you can skip individual component being
                                                removed by setting x-openapicmd-keep to true
  -V, --validate                                validate against openapi schema
  -b, --banner=<value>                          include a banner comment at the top of the generated file
  -h, --help                                    Show CLI help.

DESCRIPTION
  Generate types from openapi definition

EXAMPLES
  $ openapi typegen ./openapi.yml > openapi.d.ts

See code: src/commands/typegen.ts

Commercial support

For assistance with using openapicmd in your company, reach out at support@openapistack.co.

Contributing

openapicmd is Free and Open Source Software. Issues and pull requests are more than welcome!