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

Unknown fields are not validated. #859

Closed
vicky16898 opened this issue Sep 20, 2023 · 4 comments
Closed

Unknown fields are not validated. #859

vicky16898 opened this issue Sep 20, 2023 · 4 comments

Comments

@vicky16898
Copy link

The JSON Schema Validator appears to not raise errors when the payload includes fields that are not explicitly defined in the Swagger schema. This behavior prompts the question of whether the validator takes into account the "additionalProperties" flag specified in the Swagger definition to govern this aspect of validation.

@manuelwaltschek
Copy link

Well I guess it does, but not for sub-schemas, as it is restricted to the scope of the individual sub schemas.
https://json-schema.org/understanding-json-schema/reference/object.html#additional-properties

There was a feature in NetworkNt that subschemas are also validated when using unevalutatedProperties, but this is now restricted as of #826

So unevaluatedProperties also does not affect sub-schemas anymore, as the specification says so (although I cannot find the reference to this rule in the specs right now ;) )
This is also bugging me.

So for validating nested properties now you have to add the additionalProperties=false or unevaluatedProperties=false to each of the sub-schemas, which is redundant, but sadly how it works.

I hope I did address your issue. If you could give an example and explain what you expect, I could confirm this.

@stevehu
Copy link
Contributor

stevehu commented Feb 28, 2024

@vicky16898 @manuelwaltschek I wonder if you want to test the latest version.

@manuelwaltschek
Copy link

@stevehu has anything changed regarding this? I haven't been up to date as I'm not working with the schema validation anymore.

@stevehu
Copy link
Contributor

stevehu commented Mar 5, 2024

@justin-tay has refactored the library to resolve tons of issues and I think your issue is resolved already in the 1.3.3 version. Please verify when you have a chance. Thanks.

@stevehu stevehu closed this as completed May 30, 2024
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

No branches or pull requests

3 participants