logo

Derive Macro poem_openapi::OneOf[][src]

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

Define a OpenAPI discriminator object.

Macro parameters

AttributedescriptionTypeOptional
property_nameThe name of the property in the payload that will hold the discriminator value.stringY

Item parameters

AttributedescriptionTypeOptional
mappingRename the payload value. (Default is the object name)stringY

Examples

use poem_openapi::{Object, OneOf};

#[derive(Object, Debug, PartialEq)]
struct A {
    v1: i32,
    v2: String,
}

#[derive(Object, Debug, PartialEq)]
struct B {
    v3: f32,
}

#[derive(OneOf, Debug, PartialEq)]
#[oai(property_name = "type")]
enum MyObj {
    A(A),
    B(B),
}