#[derive(utoipa::ToSchema)]
pub enum InnerEnum {
A(String),
B(f64),
}
// this works
#[derive(utoipa::ToSchema)]
pub struct OkOuter1 {
map: Option<InnerEnum>,
}
// this works
#[derive(utoipa::ToSchema)]
pub struct OkOuter2 {
map: HashMap<String, InnerEnum>,
}
// this fails
#[derive(utoipa::ToSchema)]
pub struct BadOuter {
map: HashMap<String, Option<InnerEnum>>,
}
The (presumably) same issue also occurs for BTreeMap<String, Option<InnerEnum>>.
This seems to be a particular edge case of jsonschema type composition, as this workaround, which would describe an identical JSON-serialized document, works fine:
E.g. the following fails with a compile error:
The (presumably) same issue also occurs for
BTreeMap<String, Option<InnerEnum>>
.This seems to be a particular edge case of jsonschema type composition, as this workaround, which would describe an identical JSON-serialized document, works fine: