-
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
Support oneOf and anyOf as alternative of enum/enumNames #581
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fantastic work, thanks! My only real complaints:
-
isConstant
could use some JSDoc saying that it's used on schemas (maybe something like "Checks to see if a schema only matches a single constant value") -
isSelect
probably needs a better name and/or JSDoc. (Maybe the name is OK sinceisMultiSelect
exists, although I'm not crazy about that name either.)
Sorry it took so long to look at this!
}); | ||
}); | ||
|
||
it("should retrieve reference schema definitions", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
referenced
src/utils.js
Outdated
return false; | ||
} | ||
const itemsSchema = retrieveSchema(schema.items, definitions); | ||
return isSelect(itemsSchema); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about isSelect(schema.items, definitions)
instead?
Currently there isn't any JSDoc comment in the react-jsonschema-form sources. Should I add a simple comment or a JSDoc comment ? |
We don't have any code that does anything specific with JSDoc comments and actually most functions are not documented using JSDoc, but adding a JSDoc comment is fine. It doesn't have to be complicated -- the example on validateFormData is fine. |
@glasserc, I made all the requested changes except the renaming of |
Thanks! |
Released in v0.50.0. |
Reasons for making this change
As mentioned by @dlax in #532 enumNames keyword is not in the JSON Schema specification (neither draft-04 nor draft-06).
Another way to support choices schemas is to write them with the following structure :
or with draft-06's new
const
keyword:This PR adds basic support for oneOf/anyOf as an alternative to the non standard
enumNames
keywords.Checklist
npm run cs-format
on my branch to conform my code to prettier coding style