-
Notifications
You must be signed in to change notification settings - Fork 325
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
FeatureRequest: WARN log on additional property #828
Comments
@manuelwaltschek The JSON Schema Team introduced If I understand your need correctly, it seems to me that simply adding |
I think it will not quite solve my issue. For example, this is a snippet of my schema:
When the client sends the field "period_begin" validation does not fail since it does not match the property name, I would have to add "additionalProperties=false" to the subschema, but this is inconvenient in my opinion, when there are a lot of sub-schemas, I found it to be error prone, when you just forget it ;) |
@manuelwaltschek this library just implement a standard. The standard required to define "additionalProperties=false" on every level, any inheritance is absend here. The WARN log which you propose maybe useful for your edgecase project, but definetly will spam some others. Especially for deep jsons where we have a limited defined set of properties only for topmost level(s) |
I agree with you @kool79 but this is why I asked for it to be configurable. I've had this problem multiple times which was also hard to cover with tests, as the schema just accepted anything and clients using these schemas on our endpoints failed to map properties to the right name of the property not getting any errors at all. So adding additional validation "on-top" of the schema-validation makes me wonder why I even use that in the first place. Maybe it just isn't the right tool for the job. |
Is it possible to add warnings when a property is not included in the schema?
My use case:
Building a data modeling tool built on json-schema, having strict schemas and also using schema composition extensively.
As seen in This issue unevaluatedProperties validates recursively, but additionalProperties does not. When using "allOf" I have to use unevaluatedProperties, but when it is a self-contained schema, we are using additionalProperties=false. This does not apply to any nested object definitions and logging it would help find any instances where a client might use the wrong property name.
Edit: what do you think about a "strict mode" that is configurable so that it fails on addtionalProperties recursively?
The text was updated successfully, but these errors were encountered: