floratmin
floratmin
Aarktype
Created by floratmin on 5/21/2025 in #questions
Prevent JsonSchema for type enumerated to become anyOf
Hello, when I have type.enumerated('foo', 'bar').or(type.enumerated('foo', 'bar').array()).toJsonSchema(), the returned schema is:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{
"type": "array",
"items": {
"enum": [
"bar",
"foo"
]
}
},
{
"const": "bar"
},
{
"const": "foo"
}
]
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{
"type": "array",
"items": {
"enum": [
"bar",
"foo"
]
}
},
{
"const": "bar"
},
{
"const": "foo"
}
]
}
How can I get the following schema instead:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{
"type": "array",
"items": {
"enum": [
"bar",
"foo"
]
}
},
{
"enum": ["bar", "foo"]
}
]
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{
"type": "array",
"items": {
"enum": [
"bar",
"foo"
]
}
},
{
"enum": ["bar", "foo"]
}
]
}
1 replies