Skip to content

required keyword doesn't work with oneOf fields #2222

Open
@DrewHoo

Description

@DrewHoo

Describe the bug

If you have a oneOf field that contains both object and string type schemas, requiring that field has no effect on the string-type schema, and AFAICT there's no way to make the string-type schema required.

Expected behavior

when requiring a oneOf field that contains multiple schema types, non-object types show up as required.

Steps to reproduce the issue

Used schema:

{
  "title": "Oratrice",
  "type": "object",
  "properties": {
    "mecanique": {
      "title": "Mecanique",
      "oneOf": [
        {
          "title": "d'Analyse",
          "type": "string"
        },
        {
          "title": "Cardinale",
          "type": "object",
          "properties": {
            "cardinale": {
              "title": "name",
              "type": "string"
            }
          },
          "required": ["cardinale"]
        }
      ]
    }
  },
  "required": ["mecanique"]
}

If a (string) control is rendered for the first entry of the oneOf, the JSON Forms bindings will not indicate that this control is required.

I created a minimal reproduction in this codesandbox: https://codesandbox.io/p/sandbox/wizardly-darkness-vhrlwt?file=%2Fsrc%2FApp.tsx%3A50%2C27

Screenshots

No response

In which browser are you experiencing the issue?

Firefox 120.0

Which Version of JSON Forms are you using?

v3.1.0

Framework

Core, React

RendererSet

Other (please specify in the Additional context field)

Additional context

This is a bug in either the Core library or the React library--it happens with multiple renderer sets

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions