Skip to content

indexOfFittingSchema for oneOf doesn't work anymore if $ref is used #1991

Closed
@Fankhauser-Dominik

Description

@Fankhauser-Dominik

Describe the bug

Since Version 3.0.0-beta.2, the indexOfFittingSchema returns undefined instead, for example 0 or 1.
The Previous Versions worked fine.

If I use the same schema without any refs, it works fine.

oneOf with $ref (official oneOf Example)
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "address": {
      "type": "object",
      "properties": {
        "street_address": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "state": {
          "type": "string"
        }
      },
      "required": [
        "street_address",
        "city",
        "state"
      ],
      "additionalProperties": false
    },
    "user": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "mail": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "mail"
      ],
      "additionalProperties": false
    }
  },
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "addressOrUser": {
      "oneOf": [
        {
          "$ref": "#/definitions/address"
        },
        {
          "$ref": "#/definitions/user"
        }
      ]
    }
  },
  "required": [
    "name"
  ]
}
oneOf without $ref
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "addressOrUser": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "street_address": {
              "type": "string"
            },
            "city": {
              "type": "string"
            },
            "state": {
              "type": "string"
            }
          },
          "required": [
            "street_address",
            "city",
            "state"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "mail": {
              "type": "string"
            }
          },
          "required": [
            "name",
            "mail"
          ],
          "additionalProperties": false
        }
      ]
    }
  },
  "required": [
    "name"
  ]
}

Expected behavior

If the bound data matches a oneOf Schema, then it should have an indexOfFittingSchema.

Steps to reproduce the issue

  1. Go to https://codesandbox.io/s/vigilant-rgb-unncn8?file=/src/schema.json
  2. Because of the bound data it should render the ONEOF-1 Tab, but it renders the ONEOF-0 Tab (default behavior).
  3. Change the JsonForms versions to 3.0.0-beta.1
  4. You will see, that it now works properly

Screenshots

No response

In which browser are you experiencing the issue?

Browser independent

Framework

Core

RendererSet

Material

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions