Skip to content

Support specifying multiple types in an array #5238

Description

@Jean-Dum

Prerequisites

What theme are you using?

shadcn

Is your feature request related to a problem? Please describe.

Hello!
I saw in the documentation that "react-jsonschema-form only supports a restricted subset of this -- nullable types, in which an element is either a given type or equal to null".

When a property type is an array of more than one type, the displayed input corresponds to the first type in the array, it is impossible to switch between available types.

It is also an issue when additionalProperties is set to true, the added additional properties type is set to null
and it is impossible to switch to other types.

Describe the solution you'd like

If the property type is an array, like:

const schema: RJSFSchema = {
  type: ['string', 'number', 'boolean'],
};

Display a selector allowing to switch between those three types.

If the type isn't precised (for example when additionalProperties is set to true without specifying the schema), display a selector with all available types.

Describe alternatives you've considered

I tried to customize myself the FieldTemplate component and added a selector, but rjsf does not have anything allowing to change the type of a property, it always takes the first one in the array.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions