utoipa - Autogenerate OpenAPI documentation
Want to document your utopic api? Want it to feel as fuzzy as cold ipa? Then you are probably in need of utoipa.
Utoipa crate provides autogenerated OpenAPI documentation for Rust REST APIs. It treats code first appoach as a first class citizen and simplifies API documentation by providing simple macros for generating the documentation from your code.
It also contains Rust types of OpenAPI spec allowing you to write the OpenAPI spec only using Rust if autogeneration is not your flavor or does not fit your purpose.
In future there are plans to support more sophisticated code generation from generated OpenAPI spec and as well to support contract first approach.
Current project status
This project is currently in active development and not ready for PRODUCTION use!
The reference implementation is almost there which enables people to play around with the library. It is yet to be released to crates later on when the api and the functionalities are mature enough for wider scale adoption.
See https://github.com/juhaku/utoipa/projects for more details about the progress of the project implementation.
30 sec Lesson
Create type for API. Crusial part is the Component derive which will create OpenAPI component for the struct or enum.
Create your Get pet API.
Tie the API and Component together with the OpenApi derive which will create OpenAPI api doc for you.
;
println!;
This would produce api doc something similar to:
Goals
Eeasy of use, and easy of development along with avoinding excessive cloning and keeping perfomance in mind while developing the library. It should follow the general rust quidelines and latest conventions of the Rust.
| Goal | Status |
|---|---|
| Necessary subset implementation of OpenAPI spec in Rust | :heavy_minus_sign: Some definitions missing |
| Macros for autogenerating documentation | :heavy_check_mark: Done, but some things missing |
| Embed Swagger UI for OpenAPI documentation | :heavy_check_mark: Done |
| Embed ReDocly for OpenAPI documentation | :x: Not done |
| Integration with Actix web framework | :heavy_check_mark: Done |
| Integration with Rocker framework | :x: Not done |
| Write exessive documentation & Book & Examples | :x: Not done |
| At least 90 % tested code | :heavy_minus_sign: Still ongoing along with the other development |
Integration with other frameworks are not planned as of this stage but when the intial set of features are complete the integrations with other frameworks can be prioritized.
License
Licensed under either of Apache 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, shall be dual licensed, without any additional terms or conditions.