Skip to content

AllOf is wrong rendered #1145

Open
Open
@weismantelf

Description

@weismantelf

I have defined the following schema in my components:

            "test1": {
                "type": "object",
                "properties": {
                    "useText":
                    {
                        "type": "boolean"
                    },
                    "useSymbol":
                    {
                        "type": "boolean"
                    },
                    "useDigit":
                    {
                        "type": "boolean"
                    }

                }
            },

            "test1CtrlText":{
                "oneOf": [
                    {
                        "title" : "NO TEXT",
                        "properties": {
                            "useText":
                            {
                                "enum": [false]
                            }
                        }
                    },
                    {
                        "title" : "TEXT",
                        "properties": {
                            "useText":
                            {
                                "enum": [true]
                            },
                            "textField":
                            {
                                "type": "string"
                            }
                        },
                        "required": ["textField"]
                    }
                ]
            },

            "test1CtrlSymbol":{
                "oneOf": [
                    {
                        "title" : "NO SYMBOL",
                        "properties": {
                            "useSymbol":
                            {
                                "enum": [false]
                            }
                        }
                    },
                    {
                        "title" : "SYMBOL",
                        "properties": {
                            "useSymbol":
                            {
                                "enum": [true]
                            },
                            "symbolField":
                            {
                                "type": "string"
                            }
                        },
                        "required": ["symbolField"]
                    }
                ]
            },

            "test1CtrlDigit":{
                "oneOf": [
                    {
                        "title" : "NO Digit",
                        "properties": {
                            "useDigit":
                            {
                                "enum": [false]
                            }
                        }
                    },
                    {
                        "title" : "SYMBOL",
                        "properties": {
                            "useDigit":
                            {
                                "enum": [true]
                            },
                            "digitField":
                            {
                                "type": "string"
                            }
                        },
                        "required": ["digitField"]
                    }
                ]
            },

            "test1All": {
                "allOf": [
                    {"$ref" : "#/components/schemas/test1"},
                    {"$ref" : "#/components/schemas/test1CtrlText"},
                    {"$ref" : "#/components/schemas/test1CtrlSymbol"},
                    {"$ref" : "#/components/schemas/test1CtrlDigit"}
                ]
            }

When I use now in my response body:

    "$ref": "#/components/schemas/test1All"

The whole thing is rendered wrong as you see in the image:

image

There should be three anyOf blocks, but only one is rendered.

When I replace the the 3 last references (test1CtrlText, test1CtrlSymbol, test1CtrlDigit) against the
code of their schemas:

 "allOf": [
    {"$ref" : "#/components/schemas/test1"},
    {
        "oneOf": [
            {
                "title" : "NO TEXT",
                "properties": {
                    "useText":
                    {
                        "enum": [false]
                    }
                }
            },
            {
                "title" : "TEXT",
                "properties": {
                    "useText":
                    {
                        "enum": [true]
                    },
                    "textField":
                    {
                        "type": "string"
                    }
                },
                "required": ["textField"]
            }
        ]
    },
    {...},
    {...}
 ]

I get the following rendering:

image

Which works as it should, although the label were not rendered:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    openapiQuestions about specification, validity, and edge cases

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions