Expand description
crozier: generate SDKs from an OpenAPI document, matching Fern’s output.
The library is a small pipeline: openapi::load parses the document,
ir::build resolves it into a generation-ready ir::Ir, and
emit::generate renders that IR to Python files with minijinja. The CLI
(src/main.rs) is a thin shell over generate.
§Stability
The product is the crozier binary, not this library. The crate is
published to crates.io so cargo install crozier works and so the binary can
be built from a registry source; the library surface (including
strip_python_comments, which exists to share one comment-stripper between
the CLI’s hidden internal-strip subcommand and the e2e fixtures) is an
internal API with no semver guarantee — it may change in any release.
Depend on the CLI, not on these items.
Re-exports§
pub use emit::GeneratedFile;pub use error::Error;pub use error::Result;pub use normalize::strip_python_comments;
Modules§
- cli
- CLI parsing and dispatch. Kept in the library (not
main.rs) so it is testable in-process and measured by coverage;src/main.rsis a thin shell. - compare
crozier compare: for every generator a repository’s crozier configs declare, produce a reference SDK by running the user’sreference.command, produce crozier’s SDK, compare the two whole trees under the byte-match rules incrate::parity, and time both sides. Seedocs/compare.mdfor the contract this implements (the flags, the reference-command environment, the JSON report and the exit statuses).- config
- Generation configuration. Deliberately small: the OpenAPI document plus a few naming knobs are the entire input — there is no per-project config file.
- departures
- The catalog of crozier’s intended departures from Fern’s output, and the rule each one applies.
- document_
refusals - Structural refusals for the document-family Fern registry.
- emit
- Rendering the IR to Python source files with minijinja.
- error
- Error type for crozier. Every fallible boundary returns
Error; the CLI maps it to a non-zero exit and an actionable stderr message. - ir
- The intermediate representation: a small, generation-ready model built from the OpenAPI document, decoupling parsing from emission. Schema and property order is preserved from the document so generated output is deterministic.
- naming
- Name transforms shared by the IR builder and the emitter.
- normalize
- String-safe removal of Python
#comments. - openapi
- A pragmatic serde model of the subset of OpenAPI 3.x that crozier reads.
- parity
- The comparison engine: how crozier’s output tree is compared with a reference tree that has the shape of Fern’s Python SDK output.
- pyfmt
- Formatting generated Python by delegating to
ruff format. - refs
- Resolving
$refs that point at another document over HTTP(S) or a local path. - schema
- The public JSON Schema for a
crozier.ymlconfig file. - settings
- Layered generation settings: the schema of
crozier.yml, the pure parse/validate/merge/resolve logic, and the file discovery that reads it. - wrap
- Building Python type expressions as flat strings.
Structs§
- Generate
Args - Inputs for a generation run, mirroring the CLI’s
generateflags. - Resolved
Names - The names a generation run would use once crozier’s defaults are filled in:
what
generatederives from the API title when a name is not configured.
Constants§
- VERSION
- The version Cargo built this crate as — what
crozier --versionprints.
Functions§
- generate
- Run the full pipeline: parse the spec, build the IR, render, and write files. Returns the files written so the caller can report a count.
- render_
files - Render the files for a spec without writing them — used by tests to compare generated contents against fixtures in-process.
- resolved_
names - Resolve the names
argswould generate with, reading the document’s title for the defaults exactly asgeneratedoes.