# openapi-lib-generator A tool to generate Rust libraries from OpenAPI specifications using the [OpenAPI Generator Rust code generator](https://openapi-generator.tech/docs/generators/rust/). ## About It is available as a binary or library. ## Is this tool worth it? There are other tools like this: - [openapi_generator](https://crates.io/crates/openapi_generator) - [openapi-client-generator](https://crates.io/crates/openapi-client-generator) - [oapi_generator](https://crates.io/crates/oapi_generator) This differs from those by trying to generate self-updatable crates that include [cargo-make makefiles](https://github.com/sagiegurari/cargo-make) so as not to have to keep using this generator. ### Goal Any crate generated by this generator should be mostly self-maintainable, including in its makefile all of the commands necessary to self-update to new versions as needed. ### Progress This tool can indeed generate code. There are, however, problems with the OpenAPI Generator's Rust generator. #### Correctness As of now, there *may* be syntactical errors in the generated code. (Notably, [rustc error code e0412 (A used type name is not in scope)](https://doc.rust-lang.org/error_codes/E0412.html)) There are PR requests pending on that repo to fix these problems, but the maintainers seem really busy. FWIW, these errors may only happen if your OpenAPI specification is malformed, in which case, you're best off correcting the specification. #### Edition As of now, the generated code will be Rust 2018 edition. If the `autogeneration` CLI option is `true` (default), the CLI will try to update the edition automatically. See the generated makefile for a task that also tries this. If using that option, the generated Cargo toml will require a manual update of the `package.edition` field. ### Contributing After making changes in the generator crate, run `cargo make test-generate-with-local-path`. This will try generating a crate with the [OpenAPI Generator "Petstore" YAML spec](https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator-gradle-plugin/samples/local-spec/petstore-v3.0.yaml).