-
Notifications
You must be signed in to change notification settings - Fork 126
Open
Labels
enhancementNew feature or requestNew feature or requestrocket-okapi-codegenThis affects the rocket-okapi-codegen crateThis affects the rocket-okapi-codegen crate
Description
Using this feature rwf2/Rocket#590 results in the trait bound '[...] rocket_okapi::response::OpenApiResponderInner' is not satisfied when the enum type is as a result type in a #[openapi] endpoint function.
It would be great if #[openapi] or similar could be used on an enum deriving Responder to also derive the appropriate forwarding OpenApiResponderInner implementation for the enum.
Example:
#[openapi] // inserting okapi openapi or derive macro here?
#[derive(Responder)]
enum MyResponse {
Person(Json<Person>), // 200, json object
Nothing(NoContent), // 204, no content
}
Should generate:
impl rocket_okapi::response::OpenApiResponderInner for MyResponse {
fn responses(
gen: &mut rocket_okapi::gen::OpenApiGenerator,
) -> rocket_okapi::Result<okapi::openapi3::Responses> {
let mut responses = okapi::openapi3::Responses::default();
responses
.responses
.extend(Json::<Person>::responses(gen)?.responses);
responses
.responses
.extend(NoContent::responses(gen)?.responses);
Ok(responses)
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestrocket-okapi-codegenThis affects the rocket-okapi-codegen crateThis affects the rocket-okapi-codegen crate