Expand description
Procedural macros for the Kynos REST API framework.
Nothing here is meant to be used directly: every macro is re-exported from
kynos, and the documentation lives next to the trait each one implements.
§Why the route attributes exist
Kynos deliberately has no attribute DSL restating a handler’s signature.
utoipa’s #[utoipa::path(responses(...))] is written by hand beside the
code it describes, and nothing keeps the two in step — which is the single
most common way a generated OpenAPI document ends up wrong.
The route attributes therefore carry only what the types cannot: the method, the path, and prose. Parameters come from the handler’s arguments, responses from its return type, and neither is restated anywhere.
What the attribute does add is compile-time checking the builder form cannot do — chiefly that a path template’s variables match the handler’s path parameters.
§Why the examples here are ignored
Every expansion names ::kynos::…, which this crate cannot depend on, so a
doctest here would not compile whatever the derive emitted. The compiled
demonstrations live in crates/kynos/tests/derives.rs and the framework’s
examples; AGENTS.md records the carve-out.
Macros§
- assets
- Compiles a directory into the binary as a described asset set.
- path
- A path template validated at compile time.
- routes
- Collects operations for mounting.
Attribute Macros§
- delete
- Declares a
DELETEoperation. Seegetfor the syntax. - get
- Declares a
GEToperation. - head
- Declares a
HEADoperation. Seegetfor the syntax. - operation
- Declares an operation for a method with no dedicated attribute.
- options
- Declares an
OPTIONSoperation. Seegetfor the syntax. - patch
- Declares a
PATCHoperation. Seegetfor the syntax. - post
- Declares a
POSToperation. Seegetfor the syntax. - put
- Declares a
PUToperation. Seegetfor the syntax. - query
- Declares a
QUERYoperation. - trace
- Declares a
TRACEoperation. Seegetfor the syntax.
Derive Macros§
- ApiError
- Maps an error type to RFC 9457 problem details.
- Cookie
Params - Declares a group of request cookies.
- Header
Params - Declares a group of request or response headers.
- Multipart
Form - Declares the fields of a
multipart/form-databody, in both directions. - Path
Params - Declares a group of path parameters.
- Provider
- Declares an application context, emitting one
Providesimplementation per field. - Query
Params - Declares a group of query parameters.
- Reply
- Declares a closed set of responses, one variant per status.
- Schema
- Describes a type as JSON Schema.
- Security
Scheme - Declares a security scheme.
- Tag
- Declares a tag.