Skip to content
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

oneOf picks first schema or both in playground #2383

Closed
hardysabs2 opened this issue May 17, 2021 · 3 comments
Closed

oneOf picks first schema or both in playground #2383

hardysabs2 opened this issue May 17, 2021 · 3 comments

Comments

@hardysabs2
Copy link

Prerequisites

Description

oneOf picks first schema or both in playground, not either or

Steps to Reproduce

Use this json schema in the playground:

{
"type": "object",
"oneOf": [
{
"properties": {
"lorem": {
"type": "object",
"properties": {
"f1": {
"type": "string"
},
"f2": {
"type": "string"
}
},
"required": ["f1", "f2"]
}
},
"required": [ "lorem"
]
},
{
"properties": {
"ipsum": {
"type": "object",
"properties": {
"g1": {
"type": "string"
}
},
"required": ["g1"]
}
},
"required": [ "ipsum"
]
}
]
}

Expected behavior

When I use the dropdown to switch between schemas option 1 or option 2 and fill in the form and submit I expect either this form data

{
"lorem": {
"f1": "aa",
"f2": "aa"
}
}

or this form data

{
"ipsum": {
"g1": "aa"
}
}

Actual behavior

however with the first option I always get the first schema only (lorem above) but with the second option I always get both with the first schema empty.

{
"lorem": {},
"ipsum": {
"g1": "aa"
}
}

I don't understand why.

Also as I use the dropdown to switch between the schemas I get this error "should match exactly one schema in oneOf", even though I can successfully complete the field and submit without error.

I just want to use the dropdown to pick between two objects with properties and fill in the fields and get form data for just one of them.

Version

Playground:

https://rjsf-team.github.io/react-jsonschema-form/

@arghness
Copy link

arghness commented Jun 5, 2021

Actually, this seems to be a duplicate of #2183 ?

@heath-freenome
Copy link
Member

Closing as duplicate of #2183

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

4 participants