Skip to main content

Crate oapi_codegen

Crate oapi_codegen 

Source
Expand description

oapi-codegen — generate idiomatic Rust from OpenAPI 3 specifications.

The pipeline is: load a spec (loader), lower its component schemas into an intermediate representation (lower::schemair) and, for the server generator, its operations (lower::pathsir), then emit formatted Rust source (emit). Config mirrors oapi-codegen’s YAML configuration.

Re-exports§

pub use crate::config::Config;
pub use crate::error::Error;
pub use crate::error::Result;

Modules§

cli
Definition of the command-line interface.
config
Generator configuration, compatible with oapi-codegen’s YAML configuration files.
deps
Computing the external crate dependencies the generated code requires.
emit
Emitting the crate::ir as formatted Rust source.
error
Error types for the generator.
filter
Spec-level operation and schema filtering.
ir
Intermediate representation (IR) of generated Rust types.
loader
Loading OpenAPI documents and resolving $refs.
lower
Lowering OpenAPI documents into the intermediate representation (IR).
naming
Conversion of OpenAPI names into valid, idiomatic Rust identifiers and derivation of per-operation artifact names.

Enums§

Drift
What a comparison of generated code against an output file found.

Functions§

check_output
Compare code with the content of output_path and report the difference.
generate
Generate Rust from a spec file according to configuration, returning the source.
generate_models_string
Generate Rust models from a spec file and return the formatted source.
generate_models_to_file
Generate Rust models from a spec file and write them to output_path, creating parent directories as needed.
generate_to_file
Generate Rust from a spec file according to configuration and write it to output_path, creating parent directories as needed.
write_output
Write generated source to output_path, creating parent directories.