-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Default type to object
if undefined
#1265
Labels
Comments
Yes, I believe that makes sense. Why would you make the default type |
Yeah that would also work, though you'd then also have to check for |
I think that's it! |
domharrington
added a commit
to domharrington/react-jsonschema-form
that referenced
this issue
May 21, 2019
8 tasks
epicfaace
pushed a commit
that referenced
this issue
Jun 2, 2019
* Default type to `object` if undefined Fixes #1265 * Tidy up if statement expression as per PR review
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Description
Can we default the
type
toobject
if it's undefined? We accept user submitted JSON Schemas and this is a common thing that people miss. I'm not 100% sure if it's valid JSON Schema or not, but https://www.jsonschemavalidator.net/ appears to say the following is valid:But when passing that into this module, we get the following error:
Playground link: https://mozilla-services.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6e30sInNjaGVtYSI6eyJwcm9wZXJ0aWVzIjp7ImEiOnsidHlwZSI6InN0cmluZyJ9fX0sInVpU2NoZW1hIjp7fX0=
Steps to Reproduce
type
Expected behavior
Default
type
toobject
if it is undefinedIf
type
is set to something that is unknown, still create theUnsupportedField
e.g.type: 'someothertype'
Affected blocks of code:
Could check for undefined in here and return
object
: https://github.com/mozilla-services/react-jsonschema-form/blob/2d63594e075bba3b134ef09709c773a9ea037923/src/utils.js#L68-L84This is where it will bubble up to, but I don't think this code would have to change at all: https://github.com/mozilla-services/react-jsonschema-form/blob/2d63594e075bba3b134ef09709c773a9ea037923/src/components/fields/SchemaField.js#L49-L59
Happy to send over a PR for this if it'll get accepted!
Version
v1.5.0
The text was updated successfully, but these errors were encountered: