added additional support#458
added additional support#458riba2101 wants to merge 4 commits intorjsf-team:masterfrom riba2101:master
Conversation
|
@riba2101 Nice to see progress on this! |
|
uiSchema support is somewhat basic, would be grate to extend it but given my "no time atm to play"... |
glasserc
left a comment
There was a problem hiding this comment.
Thanks for your effort! This is a good start, but it's still quite limited. I noticed, for instance, that it's not possible to add more properties to e.g. devMap, which seems like quite a natural feature to want. And of course, it doesn't support stranger cases like additionalProperties: {}, which may be too hard/out of scope for this project.
| lib | ||
|
|
||
| /*.iml | ||
| .idea |
There was a problem hiding this comment.
Please don't commit these to the project's .gitignore. If you find them helpful, you might add them to your $HOME/.config/git/ignore (per the gitignore man page).
| "name": "test", | ||
| "devMap": { | ||
| "key": 2, | ||
| "value": 12 |
There was a problem hiding this comment.
I think this example is quite confusing. additionalProperties makes the most sense for properties with unknown and arbitrary names. The names key and value sound like two very specific names with a predefined meaning, and specifically they sound like an attempt to try to encode some entity like {"5": 12}. ({5: 12} is, of course, invalid JSON, since all keys have to be strings.) I think this is especially misleading because of the name devMap.
How about an example where the keys are really arbitrary, for example site names or URLs? I guess we'd still want the values to be numeric, so maybe it could be a map of site -> estimated user count or something?
| return true; | ||
| } | ||
| return false; | ||
| return !deepEquals(newKeys.sort(), oldKeys.sort()); |
There was a problem hiding this comment.
Please do not commit stylistic changes as part of this PR, it makes it harder to review.
| // For object defaults, only override parent defaults that are defined in | ||
| // schema.default. | ||
| defaults = mergeObjects(defaults, schema.default); | ||
| defaults = merge(defaults, schema.default); |
There was a problem hiding this comment.
Switching from the existing mergeObjects function to lodash.merge is its own topic for discussion and should not be part of this PR. It makes it seem like using lodash.merge is necessary to implement this feature, which as far as I can tell, it isn't.
| </p> | ||
| <pre>{JSON.stringify(schema)}</pre> | ||
| </div> | ||
| ); |
There was a problem hiding this comment.
Please do not change indentation, here as well as elsewhere, as it no longer matches the style of the rest of the code, and the changes themselves are hard to review. I see that you unindented the code that eslint flagged, so clearly our eslint rules aren't strict enough about enforcing "house style", but please try to match it anyhow :)
| const {definitions} = this.props.registry; | ||
| const schema = retrieveSchema(this.props.schema, definitions); | ||
| const title = (schema.title === undefined) ? name : schema.title; | ||
| if ("additionalProperties" in schema){ |
| ); | ||
| })} | ||
| </fieldset> | ||
| ); |
There was a problem hiding this comment.
I don't think it's necessary to copy and paste this entire function. There are more commonalities than differences in the two implementations, which means most parts are unchanged. Trying to review this is challenging because I have to read a whole new method rather than an enhanced version of the existing method.
| id={`${idSchema.$id}__description`} | ||
| description={schema.description} | ||
| formContext={formContext}/> : null} | ||
| {Object.keys(this.state).map((name, index) => { |
There was a problem hiding this comment.
Of the ways that this is different from the existing method, I don't understand why we no longer respect ui:order here.
| <SchemaField key={index} | ||
| name={name} | ||
| required={this.isRequired(name)} | ||
| schema={schema.additionalProperties} |
There was a problem hiding this comment.
I'm pretty sure this doesn't correctly support a schema that has both properties and additionalProperties.
| if (schema.type === "object") { | ||
| if (!schema.properties){ | ||
| return defaults; | ||
| } |
There was a problem hiding this comment.
What is this change about?
|
What is the status of this. Is it being actively worked on? |
|
Hey, sry but I'm currently seriously lacking time. Feel free to take it over |
|
Closing this PR as additionalProperties support was added in #1021. |
Reasons for making this change
added additional support #228
If this is related to existing tickets, include links to them as well.
Checklist
just use a scheme that contains the key
Schema:
formData: