Redocly / Redocly/redoc

AllOf is wrong rendered

Open
#1,145 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

openapi
Dominant language
TypeScript
Stars
25.9k
Forks
2.4k
Avg merge
13h 10m
Merged PRs (30d)
4

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported OpenAPI schema in Redoc, comparing the dereferenced $ref form with the inline allOf form. Trace how nested allOf and oneOf schemas are rendered; done means all three oneOf blocks appear correctly, with titles handled consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, react, typescript
Domain
documentation, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.