Skip to content

When using "anyOf" and no UISchema generateDefaultUISchema fails with stack overflow  #2083

Closed
@LeonardHd

Description

@LeonardHd

Describe the bug

Hi,
Thanks for this awesome library. When using JsonSchema only (and have JsonForms generate a corresponding UISchema) JsonForms fails due to a stack over flow error.

The jsonSchema (minimal example) causing the error:

{
        "type": "object",
        "anyOf": [
            {
                "required": ["Option1"]
            },
            {
                "required": ["Option2"]
            }
        ],
        "properties": {
            "Option1": {
                "type": "array",
                "items": {
                    "type": "string",
                    "enum": [
                        "A",
                        "B"
                    ]
                }
            },
            "Option2": {
                "type": "array",
                "items": {
                    "type": "string",
                    "enum": [
                        "C"
                    ]
                }
            }
        }
    }

When providing a UISchema (as of below) the form renders as expected:

{
        "type": "HorizontalLayout",
        "elements": [
            {
                "type": "Control",
                "scope": "#/properties/Option1"
            },
            {
                "type": "Control",
                "scope": "#/properties/Option2"
            }
        ]
}

Expected behavior

JsonForms derives a somewhat functional UI schema, or alternatively does not crash.

Steps to reproduce the issue

  1. Clone https://github.com/eclipsesource/jsonforms-angular-seed
  2. Set schema = {...} to example above and set uischema = null;
  3. Use npm start and open localhost:4200
    -> Browser (Chrome) crashes with Stack overflow

Working example

  1. Clone https://github.com/eclipsesource/jsonforms-angular-seed
  2. Set schema = {...} and set uischema = {...}; to example above.
  3. Use npm start and open localhost:4200 -> form is rendered as expected.

Screenshots

image

In which browser are you experiencing the issue?

Google Chrome 109.0.5414.75 (Official Build) (64-bit)

Which Version of JSON Forms are you using?

v3.0.0

Framework

Angular

RendererSet

Material

Additional context

I suspected the error to be somewhere in @jsonforms\core\src\generators\uischema.ts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions