Skip to content


Repository files navigation


Adds openapi snippets using openapi-snippet module in redoc style (x-codeSamples). This is a CLI wrapper on openapi-snippet

oclif Version Downloads/week License

Getting Started

To install:

$ npm install -g openapi-snippet-cli


Adding Snippets to a Schema

$ openapi-snippet schema.yaml -o dist/schema.yaml

The example above should add snippets to schema.yaml and output the modified schema to a new file dist/schema.yaml.

Outputting JSON

$ openapi-snippet schema.yaml -e json -o dist/schema.json

Choosing Targets

$ openapi-snippet schema.yaml -t java -t c -o dist/schema.json

The example above should add snippets for java and c using their default frameworks

$ openapi-snippet schema.yaml -t java_okhttp -o dist/schema.json

This should add snippets for 'java` using OkHttp.


  $ openapi-snippet [FILE]

  FILE  input openapi document. It will attempt to resolve references (including both internal adn external ones)


  -e, --ext=yaml|json    [default: yaml] output format
  -h, --help             show CLI help
  -o, --output=output    [default: output.yaml] output file name

  -t, --targets=targets  target snippet languages + frameworks. Can be provided multiple times. If inputting language only, defaults to one of the frameworks. Supports
                         languages supported in Defaults to adding snippets for ALL supported languages.

  -v, --version          show CLI version