1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Define a OpenAPI discriminator object.
# Macro parameters
| Attribute | description | Type | Optional |
|---------------|---------------------------------------------------------------------------------|--------|----------|
| property_name | The name of the property in the payload that will hold the discriminator value. | string | Y |
# Item parameters
| Attribute | description | Type | Optional |
|-----------|--------------------------------------------------------|--------|----------|
| mapping | Rename the payload value. (Default is the object name) | string | Y |
# Examples
```rust
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),
}
```