When generating schemas for externally tagged enums containing struct variants, the oneOf block gets embedded inside additionalProperties instead of being top-level in the schema.
I tried to debug the proc macro, but my knowledge of Rust macros is fairly lacking and I wasn't able to track down the point where the schema gets generated. If you could point me in the right direction I could open a PR to fix this.
Example
Rust
#[derive(Clone, Debug, Deserialize, Serialize, OpgModel)]
#[serde(rename_all = "camelCase")]
pub enum ExampleEnum {
First { hello: String },
Second { world: String },
}
Example payload
{
"first": {
"hello": "hi!",
}
}
{
"second": {
"world": "mondo",
}
}
Currently generated schema
"ExampleEnum": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "object",
"properties": {
"hello": {
"type": "string"
}
},
"required": [
"hello"
]
},
{
"type": "object",
"properties": {
"world": {
"type": "string"
}
},
"required": [
"world"
]
}
]
}
},
Expected Schema
"ExampleEnum": {
"oneOf": [
{
"type": "object",
"properties": {
"first": {
"type": "object",
"properties": {
"hello": {
"type": "string"
}
},
"required": [
"hello"
]
}
},
"required": [
"first"
]
},
{
"type": "object",
"properties": {
"second": {
"type": "object",
"properties": {
"world": {
"type": "string"
}
},
"required": [
"world"
]
}
},
"required": [
"second"
]
}
]
}
When generating schemas for externally tagged enums containing struct variants, the
oneOfblock gets embedded insideadditionalPropertiesinstead of being top-level in the schema.I tried to debug the proc macro, but my knowledge of Rust macros is fairly lacking and I wasn't able to track down the point where the schema gets generated. If you could point me in the right direction I could open a PR to fix this.
Example
Rust
Example payload
{ "first": { "hello": "hi!", } } { "second": { "world": "mondo", } }Currently generated schema
Expected Schema