Back to Poem

Item parameters

poem-openapi/src/docs/response_content.md

2.0.0692 B
Original Source

Define an OpenAPI response content.

Item parameters

AttributeDescriptionTypeOptional
content_typeSpecify the content type.stringY
actual_typeSpecifies the actual response typestringY

Examples

rust
use poem_openapi::{
    payload::{Binary, Json, PlainText},
    ApiResponse, ResponseContent,
};

#[derive(ResponseContent)]
enum MyResponseContent {
    A(Json<i32>),
    B(PlainText<String>),
    C(Binary<Vec<u8>>),
}

#[derive(ApiResponse)]
enum MyResponse {
    #[oai(status = 200)]
    Ok(MyResponseContent),
}