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"
        }
    ]
}

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"]
        }
    ]
}
Was this page helpful?