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.
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, all of which are disabled by default:
Feature | Description |
---|---|
chrono | Integrate with the chrono crate. |
Example
use TcpListener;
use ;
;
async
Run example
Open http://localhost:3000/ui
in your browser, you will see the Swagger UI
that contains these API definitions.
> cargo run --example hello_world
> curl http://localhost:3000
hello!
> curl http://localhost:3000\?name\=sunli
hello, sunli!