-
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
added additional support #458
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"... |
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.
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.
@@ -4,3 +4,5 @@ build | |||
dist | |||
lib | |||
|
|||
/*.iml | |||
.idea |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not commit stylistic changes as part of this PR, it makes it harder to review.
@@ -112,7 +112,7 @@ function computeDefaults(schema, parentDefaults, definitions={}) { | |||
if (isObject(defaults) && isObject(schema.default)) { | |||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 schema = retrieveSchema(this.props.schema, definitions); | ||
const title = (schema.title === undefined) ? name : schema.title; | ||
if ("additionalProperties" in schema){ |
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.
Nit: Space before {
); | ||
})} | ||
</fieldset> | ||
); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this doesn't correctly support a schema that has both properties
and additionalProperties
.
@@ -129,6 +129,10 @@ function computeDefaults(schema, parentDefaults, definitions={}) { | |||
} | |||
// We need to recur for object schema inner default values. | |||
if (schema.type === "object") { | |||
if (!schema.properties){ | |||
return defaults; | |||
} |
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.
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: