Repository navigation
v0.6.0
Breaking
OpenAPI bodies are now documented only through RequestBodySchema /
ResponseBodySchema: the #[routes] macro probes the body parameter's type
and the return type for the traits instead of matching Json<T> /
JsonResult<T> / Bytes / … by name, and R2E implements the traits for its
own types. Handlers using framework types need no change; the developer
migration is docs/migration/response-schema.md.
- Breaking:
RouteInforeshaped.request_body_type,
request_body_schema,request_body_content_typeand
request_body_requiredare replaced by
request_body: Option<RequestBody { content_type, schema, required }>plus
request_body_unmapped: Option<String>;response_typeand
response_schemaare replaced byresponse_contents: Vec<ResponseContent>
(response_unmappedis kept). Struct literals add
request_body: None, request_body_unmapped: None, response_contents: Vec::new(). - Breaking:
SchemaGapvariants.SchemalessRequestBodyand
SchemalessResponseBodyare gone — a schemaless body renders from its media
type (text/*→ string,application/octet-stream→ binary string, form
media types → object) and is not a gap.MissingRequestBody { type_name }
is new;MissingResponseBodyandErrorBodyInlinedare unchanged. - Breaking:
Json<T>withT: !JsonSchemais undocumented. It was
rendered as a genericobject; it now has no body in the spec and is
warned about once at boot (MissingRequestBody/MissingResponseBody).
Deriveschemars::JsonSchemaon the DTO. - Breaking: component names are schemars'
schema_name()—Vec<User>
isArray_of_User(wasVec_User),Option<User>isNullable_User.
Generated clients and tests pinningcomponents/schemaskeys must follow. - Breaking:
Stringreturns document a body.String/&'static str/
Cow<'static, str>return types (andHtml<T>,Bytes,Vec<u8>) carry
their media type through theirResponseBodySchemaimpl instead of "no
schema". - Breaking:
MultipartSchema::schema_name()is required (the
#[derive(FromMultipart)]emits it; hand-written impls add it). - Breaking:
schema_ofmoved tor2e_core::di::meta::schema_ofbehind
the newr2e-corefeatureopenapi(r2e-openapienables it and keeps
ther2e_openapi::schema_ofre-export). - Breaking:
#[returns(T)]widened.Tis probed for
ResponseBodySchemafirst, then asJson<T>; existingJsonSchemauses
are unchanged, a custom multi-media-type response type now works too.
Added
RequestBodySchema/ResponseBodySchemafor every framework type
(r2e_core::web::body_schema):Json<T>,Form<T>,Bytes,String,
Multipart,TypedMultipart<T>on the request side;Json<T>,String,
&'static str,Cow<'static, str>,Html<T>,Bytes,Vec<u8>,(),
StatusCode,Redirect,Sse<S>on the response side, with blanket
Result<T, E>→Tand(StatusCode, T)/(HeaderMap, T)/
(StatusCode, HeaderMap, T)→T. Any alias (ApiResult<T>,
anyhow::Result<T>) is therefore documented.Option<..>around a body
extractor →required: false.ResponseBodySchema(r2e_core::di::meta): a custom response type
lists the media types it can be served as (ResponseContent::json/
event_stream/text/html/binary/new); the OpenAPI builder
documents onecontententry per media type under the success status. A
handler that answers JSON or SSE depending on the request can return a typed
enum instead ofResponseand keep a documented body.RequestBodySchema::body_schema()defaults toNone, so a schemaless
extractor only declarescontent_type()andrejection_kinds().RequestBody,ResponseContent::html()/::binary()and
OCTET_STREAMinr2e_core::di::meta;r2e-corefeatureopenapi
(schemars) gatingschema_ofand theJson<T>schemas — without it the
Json<T>impls still document media type and rejection kinds, schema-less.- Boot warning
SchemaGap::MissingRequestBodyfor a body-position
parameter withoutRequestBodySchema, the request-side twin of
MissingResponseBody.