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

Document a gotcha with additionalProperties #1018

Closed
wants to merge 1 commit into from
Closed

Document a gotcha with additionalProperties #1018

wants to merge 1 commit into from

Conversation

loganvolkers
Copy link
Contributor

Relates to #848 #902 #992 (and maybe others).

Reasons for making this change

It seems like a lot of people are running into the same problem, this will help them avoid it earlier and be more clear about the current limitations of the library.

Checklist

  • I'm updating documentation
    • I've checked the rendering of the Markdown text I've added
    • If I'm adding a new section, I've updated the Table of Content
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • I've run npm run cs-format on my branch to conform my code to prettier coding style
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@glasserc
Copy link
Contributor

Thanks for submitting this, and sorry for taking so long to respond to it. This reads like a pretty mild warning but it almost sounds like it's describing a bug. Is it actually a bug? Is using additionalProperties: false incorrect somehow? If not, is there a workaround -- something else that should be used?

@loganvolkers
Copy link
Contributor Author

#848 has a pretty good example of the behaviour. Using additionalProperties: false will produce incorrect results and break things. There may be a fix for this that would delete additional properties from the output, but would be hard to work.

Either way, it is a limitation that seems to be commonly encountered, so it should be more clearly documented.

Copy link
Contributor

@glasserc glasserc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add it to the FAQ instead of "schema support status"? "Schema dependencies" as a concept is kind of unique to rjsf.

Can we write up a definitive issue explaining what the issue is and why we believe it will be hard to fix, and link to that? We can pick one of the existing three issues or we can create a new one, but the others should be closed as dupes of the definitive one.

@jericmason jericmason mentioned this pull request Jan 21, 2019
3 tasks
@@ -1744,6 +1744,7 @@ This component follows [JSON Schema](http://json-schema.org/documentation.html)
* `anyOf`, `allOf`, and `oneOf`, or multiple `types` (i.e. `"type": ["string", "array"]`
Nobody yet has come up with a PR that adds this feature with a simple and easy-to-understand UX.
You can use `oneOf` with [schema dependencies](#schema-dependencies) to dynamically add schema properties based on input data but this feature does not bring general support for `oneOf` elsewhere in a schema.
* `"additionalProperties":false` when used with [schema dependencies](#schema-dependencies) will not remove the extra properties and produce invalid schemas. It is recommended to avoid setting `"additionalProperties":false`. See [#848](https://github.com/mozilla-services/react-jsonschema-form/issues/848) [#902](https://github.com/mozilla-services/react-jsonschema-form/issues/902) [#992](https://github.com/mozilla-services/react-jsonschema-form/issues/992)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the wording here? I can't tell if this means "will not remove the extra properties and will produce invalid schemas" or "will not remove the extra properties and will not produce invalid schemas"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, can you make your change in the docs directory instead of the README? Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing! I'll create an fresh pull request since this one is a bit stale from your new changes.

Also FYI both @jericmason work for saasquatch.com and would be happy to help contribute regularly to this project in any way. We have 4-5 developers that spend every day building using this library.

Copy link
Member

@epicfaace epicfaace Jan 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's great! Let me know what kind of feature ideas / bugs you come across; I'll try to be as responsive as possible to new ideas / PRs.

@loganvolkers
Copy link
Contributor Author

Replaced with #1149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants