Skip to content

Adding ‘null’ and ‘object’ type to property values for a schema #2411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RhysMAdey opened this issue Jan 16, 2025 · 1 comment
Open

Comments

@RhysMAdey
Copy link

Describe the bug

Hi,

I am trying to set a ‘type: [‘null’, ‘object’]’ for a schema item with the below code as an example:

schema={{
     type: 'object',
     properties: {
          name: {
               type: 'string',
               description: 'Name example'
          },
          geometry: {
               type: ['null', 'object'],
               properties: {
                    shape: {
                         type: 'string'
                         description: 'Example geometry shape property'
                    },
                    etc........
               }
          }
     }
}}

When I put this schema into my code it kills my app. Adding in type: 'object' it works fine.

Is it allowed to have type: ['null', 'object'] as I have done in the geometry section above?

Expected behavior

both types null and object will be applied to a properties property.

Steps to reproduce the issue

add

{
     type: 'object',
     properties: {
          name: {
               type: 'string',
               description: 'Name example'
          },
          geometry: {
               type: ['null', 'object'],
               properties: {
                    shape: {
                         type: 'string'
                         description: 'Example geometry shape property'
                    },
                    etc........
               }
          }
     }
}

into the schema option of JSON forms

Screenshots

No response

Which Version of JSON Forms are you using?

3.4.1

Package

No response

Additional context

No response

@klcd
Copy link

klcd commented Apr 2, 2025

Any directions how this could be fixed? In my json-schemas I often have properties like this


        "config": {
            "anyOf": [
                {
                    "$ref": "#/$defs/config"
                },
                {
                    "type": "null"
                }
            ],
            "default": null,
        }

which afaik would better represented by the above.

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

No branches or pull requests

3 participants