Utoipa
Simple, Fast, Code first and Compile time generated OpenAPI documentation for Rust
Install / Use
/learn @juhaku/UtoipaREADME
utoipa - Auto-generated OpenAPI documentation
Pronounced /u:ˈtoʊ:i.pɑ/ or /u:ˈtoʊˌaɪ.piˈeɪ/ whatever works better for you.
Want to have your API documented with OpenAPI? But don't want to be bothered
with manual YAML or JSON tweaking? Would like it to be so easy that it would almost
be utopic? Don't worry: utoipa is here to fill this gap. It aims to do, if not all, then
most of the heavy lifting for you, enabling you to focus on writing the actual API logic instead of
documentation. It aims to be minimal, simple and fast. It uses simple proc macros which
you can use to annotate your code to have items documented.
The utoipa crate provides auto-generated OpenAPI documentation for Rust REST APIs. It treats
code-first approach 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 the OpenAPI spec, allowing you to write the OpenAPI spec only using Rust if auto generation is not your flavor or does not fit your purpose.
Long term goal of the library is to be the place to go when OpenAPI documentation is needed in any Rust codebase.
Utoipa is framework-agnostic, and could be used together with any web framework, or even without one. While being portable and standalone, one of its key aspects is simple integration with web frameworks.
Choose your flavor and document your API with ice-cold IPA
|Flavor|Support|
|--|--|
|actix-web|Parse path, path parameters and query parameters, recognize request body and response body, utoipa-actix-web bindings. See more at docs|
|axum|Parse path and query parameters, recognize request body and response body, utoipa-axum bindings. See more at docs|
|rocket| Parse path, path parameters and query parameters, recognize request body and response body. See more at docs|
|Others*| Plain utoipa without extra flavor. This gives you all the basic benefits listed below in Features section but with little less automation.|
Others* = For example warp but could be anything.
Refer to the existing examples to find out more.
Features
- OpenAPI 3.1
- Pluggable, easy setup and integration with frameworks.
- No bloat, enable what you need.
- Support for generic types
- Note!<br>
Tuples, arrays and slices cannot be used as generic arguments on types. Types implementing
ToSchemamanually should not have generic arguments, as they are not composeable and will result compile error.
- Note!<br>
Tuples, arrays and slices cannot be used as generic arguments on types. Types implementing
- Automatic schema collection from usages recursively.
- Request body from either handler function arguments (if supported by framework) or from
request_bodyattribute. - Response body from response
bodyattribute or responsecontentattribute.
- Request body from either handler function arguments (if supported by framework) or from
- Various OpenAPI visualization tools supported out of the box.
- Rust type aliases via
utoipa-config.
What's up with the word play?
The name comes from the words utopic and api where uto are the first three letters of utopic
and the ipa is api reversed. Aaand... ipa is also an awesome type of beer :beer:.
Crate Features
macrosEnableutoipa-genmacros. This is enabled by default.yaml: Enables serde_norway serialization of OpenAPI objects.actix_extras: Enhances actix-web integration with being able to parsepath,pathandqueryparameters from actix web path attribute macros. See docs or examples for more details.rocket_extras: Enhances rocket framework integration with being able to parsepath,pathandqueryparameters from rocket path attribute macros. See docs or examples for more details.axum_extras: Enhances axum framework integration allowing users to useIntoParamswithout defining theparameter_inattribute. See docs or examples for more details.debug: Add extra traits such as debug traits to openapi definitions and elsewhere.chrono: Add support for chronoDateTime,Date,NaiveDate,NaiveDateTime,NaiveTimeandDurationtypes. By default these types are parsed tostringtypes with additionalformatinformation.format: date-timeforDateTimeandNaiveDateTimeandformat: dateforDateandNaiveDateaccording RFC3339 asISO-8601. To override defaultstringrepresentation users have to usevalue_typeattribute to override the type. See docs for more details.time: Add support for timeOffsetDateTime,PrimitiveDateTime,Date, andDurationtypes. By default these types are parsed asstring.OffsetDateTimeandPrimitiveDateTimewill usedate-timeformat.Datewill usedateformat andDurationwill not have any format. To override defaultstringrepresentation users have to usevalue_typeattribute to override the type. See docs for more details.jiff_0_2Add support for jiff 0.2Timestamp,Zoned, andcivil::Datetypes. By default these types are parsed asstring.TimestampandZonedwill usedate-timeformat.civil::Datewill usedateformat. To override defaultstringrepresentation users have to usevalue_typeattribute to override the type. See docs for more details.decimal: Add support for rust_decimalDecimaltype. By default it is interpreted asString. If you wish to change the format you need to override the type. See thevalue_typein component derive docs.decimal_float: Add support for rust_decimalDecimaltype. By default it is interpreted asNumber. This feature is mutually exclusive with decimal and allow to change the default type used in your documentation forDecimalmuch likeserde_with_floatfeature exposed by rust_decimal.uuid: Add support for uuid.Uuidtype will be presented asStringwith formatuuidin OpenAPI spec.ulid: Add support for ulid.Ulidtype will be presented asStringwith formatulidin OpenAPI spec.url: Add support for url.Urltype will be presented asStringwith formaturiin OpenAPI spec.smallvec: Add support for smallvec.SmallVecwill be treated asVec.openapi_extensions: Adds traits and functions that provide extra convenience functions. See therequest_bodydocs for an example.repr: Add support for repr_serde'srepr(u*)andrepr(i*)attributes to unit type enums for C-like enum representation. See docs for more details.preserve_order: Preserve order of properties when serializing the schema for a component. When enabled, the properties are listed in order of fields in the corresponding struct definition. When disabled, the properti
Related Skills
bluebubbles
339.3kUse when you need to send or manage iMessages via BlueBubbles (recommended iMessage integration). Calls go through the generic message tool with channel="bluebubbles".
gh-issues
339.3kFetch GitHub issues, spawn sub-agents to implement fixes and open PRs, then monitor and address PR review comments. Usage: /gh-issues [owner/repo] [--label bug] [--limit 5] [--milestone v1.0] [--assignee @me] [--fork user/repo] [--watch] [--interval 5] [--reviews-only] [--cron] [--dry-run] [--model glm-5] [--notify-channel -1002381931352]
healthcheck
339.3kHost security hardening and risk-tolerance configuration for OpenClaw deployments
himalaya
339.3kCLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
