Derive Macro poem_openapi::ApiRequest

source ·
#[derive(ApiRequest)]
{
    // Attributes available to this derive:
    #[oai]
}
Expand description

Define a OpenAPI request.

Item parameters

AttributeDescriptionTypeOptional
content_typeSpecify the content type.stringY

Examples

use poem_openapi::{
    payload::{Json, PlainText},
    ApiRequest, Object,
};

#[derive(Object)]
struct Pet {
    id: String,
    name: String,
}

#[derive(ApiRequest)]
enum CreatePet {
    /// This request receives a pet in JSON format(application/json).
    CreateByJSON(Json<Pet>),
    /// This request receives a pet in text format(text/plain).
    CreateByPlainText(PlainText<String>),
}