You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if it's possible for an enum that derives IntoResponses to specify a body for the whole enum (or per variant for that matter). For example, I have the following enum:
use displaydoc::Display;use thiserror::Error;use utoipa_gen::{IntoResponses};#[derive(Debug,Display,Error,IntoResponses)]pubenumRouteError{/// No active tenant could be found for the provided tenant key#[response(status = FORBIDDEN)]TenantKeyNotFound,/// User agent header is required when user agent is not set in request JSON#[response(status = BAD_REQUEST)]MissingUserAgent,}
But RouteError implements axum's IntoResponse trait which will transform the enum into a struct and sends that as the body instead of the enum variant itself:
use utoipa_gen::{ToSchema};#[derive(Debug,Serialize,ToSchema)]pubstructErrorDto{pubstatus:u16,pubmessage:String,}
Is it possible to let Utoipa know that this conversion is happening and include it as the response body in the OpenAPI schema?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi!
I was wondering if it's possible for an enum that derives
IntoResponses
to specify a body for the whole enum (or per variant for that matter). For example, I have the following enum:And include it in the route like so:
But
RouteError
implements axum'sIntoResponse
trait which will transform the enum into a struct and sends that as the body instead of the enum variant itself:Is it possible to let Utoipa know that this conversion is happening and include it as the response body in the OpenAPI schema?
Beta Was this translation helpful? Give feedback.
All reactions