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

fix: fix bad validation of definitions #616

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aloisklink
Copy link
Contributor

Sometimes, traverse accidentally traverses a non-schema object, e.g. instead traversing the properties object of a schema.

This then causes validation errors if one of these properties is "invalid" (e.g. you have a key called deprecated).

Using traverse instead of traverseObjectKeys seems to fix this, since then we don't traverse on objects that contain BLACKLISTED_KEYS.

For an example, see the test case I added. On the current master branch, shows the following error:

[
  'Error at key "properties" in file "deprecated": deprecated must be a boolean'
]

For a real world use-case, I was trying to use the OpenAPI 3.1 JSON Schema in my app and I got this validation error.

Sometimes, `traverse` accidentally traverses a non-schema object,
e.g. instead traversing the `properties` object of a schema.

This then causes validation errors if one of these properties is
"invalid" (e.g. you have a key called `deprecated`).

Using `traverse` instead of `traverseObjectKeys` seems to fix this,
since then we don't traverse on objects that contain `BLACKLISTED_KEYS`.
Comment on lines +34 to +35
schema: {
myDefinedSchema: {
Copy link
Owner

Choose a reason for hiding this comment

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

What does this mean? schema should be a JSON Schema here. ie. either use the key schema or myDefinedSchema, but don't nest them like this.

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.

2 participants