--- 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. ```text openapi-generator-cli help usage: openapi-generator-cli [] The most commonly used openapi-generator-cli commands are: author Utilities for authoring generators or customizing templates. batch Generate code in batch via external configs. config-help Config help for chosen lang generate Generate code with the specified generator. help Display help information about openapi-generator 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 used in tooling See 'openapi-generator-cli help ' for more information on a specific command. ``` ## version The version command provides version information, returning either the version by default, the git commit sha when passed `--sha`, or verbose output when passed `--full`. ```text NAME openapi-generator-cli version - Show version information used in tooling SYNOPSIS openapi-generator-cli version [--full] [--sha] OPTIONS --full Full version details --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. ```text openapi-generator-cli 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-cli 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 ```text openapi-generator-cli help config-help NAME openapi-generator-cli config-help - Config help for chosen lang SYNOPSIS openapi-generator-cli config-help [(-f | --format )] [--feature-set] [--full-details] [(-g | --generator-name )] [--import-mappings] [--instantiation-types] [--language-specific-primitive] [--markdown-header] [--named-header] [(-o | --output )] [--reserved-words] OPTIONS -f , --format Write output files in the desired format. Options are 'text', 'markdown' or 'yamlsample'. Default is 'text'. --feature-set displays feature set as supported by the generator --full-details displays CLI options as well as other configs/mappings (implies --instantiation-types, --reserved-words, --language-specific-primitives, --import-mappings, --supporting-files) -g , --generator-name generator to get config help for --import-mappings displays the default import mappings (types and aliases, and what imports they will pull into the template) --instantiation-types displays types used to instantiate simple type/alias names --language-specific-primitive displays the language specific primitives (types which require no additional imports, or which may conflict with user defined model names) --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 --reserved-words displays the reserved words which may result in renamed model or property names ``` 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-cli 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. ```text openapi-generator-cli 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 [(-l | --language )] [(-n | --name )] [(-o | --output )] [(-p | --package )] [(-t | --type )] OPTIONS -l , --language the implementation language for the generator class -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). ```text openapi-generator-cli 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-cli 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-cli 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-cli 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. ```text openapi-generator-cli 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 )] [--dry-run] [(-e | --engine )] [--enable-post-process-file] [(-g | --generator-name )] [--generate-alias-as-model] [--git-host ] [--git-repo-id ] [--git-user-id ] [--global-property ...] [--group-id ] [--http-user-agent ] [(-i | --input-spec )] [--ignore-file-override ] [--import-mappings ...] [--instantiation-types ...] [--invoker-package ] [--language-specific-primitives ...] [--legacy-discriminator-behavior] [--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-operation-example] [--skip-validate-spec] [--strict-spec ] [(-t