This document contains the help content for the oapi-codegen command-line program.
Generate client and server boilerplate from OpenAPI 3 specifications
Usage: oapi-codegen [OPTIONS] --config-file <CONFIG_FILE> <SPEC_FILE>
Examples:
oapi-codegen --config-file oapi-codegen.yaml --output-file src/api.rs api.yaml
oapi-codegen --config-file oapi-codegen.yaml api.yaml
You must provide a configuration file.
The configuration file must enable at least one artifact.
You must set output with --output-file or the output: configuration key:
output: src/api.rs generate: models: true std-http-server: true client: true
<SPEC_FILE>— Path to the OpenAPI 3 specification (YAML or JSON)
-
-c,--config-file <CONFIG_FILE>— Path to anoapi-codegenYAML configuration file (required) -
-o,--output-file <OUTPUT_FILE>— Output file path (overrides configurationoutput:). Required unless the configuration setsoutput: -
--check— Compare the generated code with the output file, and write nothing.The exit code is 0 when the output file holds the generated code. The exit code is 1 when the file differs, or when the file is absent. Use this in continuous integration to make stale output a failed build. This flag reports no dependencies, because it adds none.
-
--install-deps— After the write, runcargo addfor each required crate.If set, this runs with no prompt. If stdin is interactive and the flag is not set, the CLI asks first. If stdin is not interactive and the flag is not set, the CLI prints only the list.
cargo addtargets the package whoseCargo.tomlis nearest output. It merges with an existing declaration. A crate that already exists is updated in place.