Open tiagoskaneta opened 2 years ago
I ran into the same problem while generating OpenAPI specification using aide. The managed to work around this issue and documented all the options I come up with in this issue.
Based on my research your solution would be to use untagged enums.
#[derive(JsonSchema)]
#[serde(untagged)]
pub enum MyEnum {
Foo(String),
Bar(String),
}
which would generate (OpenAPI settings)
"MyEnum": {
"oneOf": [
{
"$ref": "#/components/schemas/Foo"
},
{
"$ref": "#/components/schemas/Bar"
},
],
Hello,
Is it possible to make the schema for an enum to use $refs instead of having all the variants in a single oneOf block?
For example, I have the following:
which outputs:
Ideally I would like to have the
MyEnum
defined as such:Thank you in advance.