Fast and Type-Safe OpenAPI implementation for Poem.
*** `Poem-openapi` allows you to easily implement APIs that comply with the `OpenAPIv3` specification. It uses procedural macros to generate a lots of boilerplate code, so that you only need to focus on the more important business implementations. * [Docs](https://docs.rs/poem-openapi) * [Cargo package](https://crates.io/crates/poem-openapi) ## Features * **Type safety** If your codes can be compiled, then it is fully compliant with the `OpenAPI v3` specification. * **Rustfmt friendly** Do not create any DSL that does not conform to Rust's syntax specifications. * **IDE friendly** Any code generated by the procedural macro will not be used directly. * **Minimal overhead** All generated code is necessary, and there is almost no overhead. ## Crate features To avoid compiling unused dependencies, Poem gates certain features, some of which are disabled by default: | Feature | Description | |--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| | camino | Integrate with the [`camino` crate](https://crates.io/crates/camino). | | chrono | Integrate with the [`chrono` crate](https://crates.io/crates/chrono). | | time | Integrate with the [`time` crate](https://crates.io/crates/time). | | humantime | Integrate with the [`humantime` crate](https://crates.io/crates/humantime) | | openapi-explorer | Add OpenAPI Explorer support | | swagger-ui | Add swagger UI support | | rapidoc | Add RapiDoc UI support | | redoc | Add Redoc UI support | | scalar | Add Scalar UI support | | stoplight-elements | Add Stoplight Elements UI support | | email | Support for email address string | | hostname | Support for hostname string | | ulid | Integrate with the [`ulid` crate](https://crates.io/crates/ulid) | | uuid | Integrate with the [`uuid` crate](https://crates.io/crates/uuid) | | url | Integrate with the [`url` crate](https://crates.io/crates/url) | | geo | Integrate with the [`geo-types` crate](https://crates.io/crates/geo-types) | | bson | Integrate with the [`bson` crate](https://crates.io/crates/bson) | | rust_decimal | Integrate with the [`rust_decimal` crate](https://crates.io/crates/rust_decimal) | | prost-wkt-types | Integrate with the [`prost-wkt-types` crate](https://crates.io/crates/prost-wkt-types) | | static-files | Support for static file response | | websocket | Support for websocket | | sonic-rs | Uses [`sonic-rs`](https://github.com/cloudwego/sonic-rs) instead of `serde_json`. Pls, checkout `sonic-rs` requirements to properly enable `sonic-rs` capabilities | ## Safety This crate uses `#![forbid(unsafe_code)]` to ensure everything is implemented in 100% Safe Rust. ## Example ```rust use poem::{listener::TcpListener, Route}; use poem_openapi::{param::Query, payload::PlainText, OpenApi, OpenApiService}; struct Api; #[OpenApi] impl Api { #[oai(path = "/hello", method = "get")] async fn index(&self, name: Query