--- id: usage title: Usage --- Options for OpenAPI Generator are the same whether you're using the CLI, Maven/Gradle Plugins, or Online generation options. This page demonstrates navigating the options via CLI. Commands are presented here in a logical progression as a tutorial, but you're welcome to skip directly to the [generate](#generate) command. ## help The `help` option lists all commands available to the CLI. ```bash openapi-generator help usage: openapi-generator-cli [] The most commonly used openapi-generator-cli commands are: config-help Config help for chosen lang generate Generate code with the specified generator. help Display help information list Lists the available generators meta MetaGenerator. Generator for creating a new template set and configuration for Codegen. The output will be based on the language you specify, and includes default templates to include. validate Validate specification version Show version information See 'openapi-generator-cli help ' for more information on a specific command. ``` ## version The version command provides version information, returning either the semver version by default or the git sha when passed `--sha`. ```bash NAME openapi-generator-cli version - Show version information SYNOPSIS openapi-generator-cli version [--sha] OPTIONS --sha Git commit SHA version ``` ## list The `list` command outputs a formatted list of every available generator. Pass the `-s/--short` option if you would like a CSV output for easy parsing. ```bash openapi-generator help list NAME openapi-generator-cli list - Lists the available generators SYNOPSIS openapi-generator-cli list [(-i | --include )] [(-s | --short)] OPTIONS -i , --include comma-separated list of stability indexes to include (value: all,beta,stable,experimental,deprecated). Excludes deprecated by default. -s, --short shortened output (suitable for scripting) ``` Example: ```bash openapi-generator list -s | tr ',' '\n' ``` For the full list of generators, refer to the [Generators List](./generators.md). ## config-help The `config-help` option provides details about ```bash openapi-generator help config-help NAME openapi-generator-cli config-help - Config help for chosen lang SYNOPSIS openapi-generator-cli config-help [(-f | --format )] [(-g | --generator-name )] [--markdown-header] [--named-header] [(-o | --output )] OPTIONS -f , --format Write output files in the desired format. Options are 'text', 'markdown' or 'yamlsample'. Default is 'text'. -g , --generator-name generator to get config help for --markdown-header When format=markdown, include this option to write out markdown headers (e.g. for docusaurus). --named-header Header includes the generator name, for clarity in output -o , --output Optionally write help to this location, otherwise default is standard output ``` The option of note is `-g/--generator-name` (other options are exposed for tooling). You may pass any generator name (see [list](#list) command) to `-g`, and options specific to that generator will be displayed. Some generators have _many_ options, while others may have only a few. Example: ```bash openapi-generator config-help -g go ``` Outputs: ```text CONFIG OPTIONS packageName Go package name (convention: lowercase). (Default: openapi) hideGenerationTimestamp Hides the generation timestamp when files are generated. (Default: true) packageVersion Go package version. (Default: 1.0.0) withGoCodegenComment whether to include Go codegen comment to disable Go Lint and collapse by default in GitHub PRs and diffs (Default: false) withXml whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML) (Default: false) prependFormOrBodyParameters Add form or body parameters to the beginning of the parameter list. (Default: false) ``` To pass these go client generator-specific options to the `generate` command for a go client, use the `--additional-properties` option. See the [generate](#generate) command section for an example. ## meta The `meta` command creates a new Java class and template files, used for creating your own custom templates. ```bash openapi-generator help meta NAME openapi-generator-cli meta - MetaGenerator. Generator for creating a new template set and configuration for Codegen. The output will be based on the language you specify, and includes default templates to include. SYNOPSIS openapi-generator-cli meta [(-n | --name )] [(-o | --output )] [(-p | --package )] [(-t | --type )] OPTIONS -n , --name the human-readable name of the generator -o , --output where to write the generated files (current dir by default) -p , --package the package to put the main class into (defaults to org.openapitools.codegen) -t , --type the type of generator that is created ``` For an in-depth example of using the `meta` command, see [Customization](./customization.md). ## validate The `validate` command allows you to validate an input specification, optionally providing recommendations for error fixes or other improvements (if available). ```bash openapi-generator help validate NAME openapi-generator-cli validate - Validate specification SYNOPSIS openapi-generator-cli validate (-i | --input-spec ) [--recommend] OPTIONS -i , --input-spec location of the OpenAPI spec, as URL or file (required) --recommend ``` Valid Spec Example (using [petstore-v3.0.yaml](https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator-gradle-plugin/samples/local-spec/petstore-v3.0.yaml)) ```bash openapi-generator validate -i petstore-v3.0.yaml ``` ```text Validating spec (petstore-v3.0.yaml) No validation issues detected. ``` Invalid Spec Example (using [petstore-v3.0-invalid.yaml](https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator-gradle-plugin/samples/local-spec/petstore-v3.0-invalid.yaml)): ```bash openapi-generator validate -i petstore-v3.0-invalid.yaml ``` ```text Validating spec (petstore-v3.0-invalid.yaml) Errors: -attribute info is missing [error] Spec has 1 errors. ``` ## completion Although not documented in the `help` output, the CLI offers a `completion` command, which can be used for auto-completion. This command takes one or more parameters representing the args list you would otherwise pass to `openapi-generator`. For example: ```bash openapi-generator completion config-help -o --output --named-header -g --generator-name -f --format --markdown-header ``` An example bash completion script can be found in the repo at [scripts/openapi-generator-cli-completion.bash](https://github.com/OpenAPITools/openapi-generator/blob/master/scripts/openapi-generator-cli-completion.bash). ## generate The `generate` command is the workhorse of the generator toolset. As such, it has _many_ more options available than the previous commands. The abbreviated options are below, but you may expand the full descriptions. ```bash openapi-generator help generate NAME openapi-generator-cli generate - Generate code with the specified generator. SYNOPSIS openapi-generator-cli generate [(-a | --auth )] [--api-name-suffix ] [--api-package ] [--artifact-id ] [--artifact-version ] [(-c | --config )] [-D ...] [--dry-run] [(-e | --engine )] [--enable-post-process-file] [(-g | --generator-name )] [--generate-alias-as-model] [--git-host ] [--git-repo-id ] [--git-user-id ] [--group-id ] [--http-user-agent ] (-i | --input-spec ) [--ignore-file-override ] [--import-mappings ...] [--instantiation-types ...] [--invoker-package ] [--language-specific-primitives ...] [--library ] [--log-to-stderr] [--minimal-update] [--model-name-prefix ] [--model-name-suffix ] [--model-package ] [(-o | --output )] [(-p | --additional-properties )...] [--package-name ] [--release-note ] [--remove-operation-id-prefix] [--reserved-words-mappings ...] [(-s | --skip-overwrite)] [--server-variables ...] [--skip-validate-spec] [--strict-spec ] [(-t