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

lack of strictSchema in ajv options results in silent typos #673

Open
2 tasks done
autopulated opened this issue Jan 10, 2024 · 0 comments · May be fixed by #674
Open
2 tasks done

lack of strictSchema in ajv options results in silent typos #673

autopulated opened this issue Jan 10, 2024 · 0 comments · May be fixed by #674

Comments

@autopulated
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

strictSchema is set to false in the ajv options (and overrides any user-provided ajv: options to the constructor, so it cannot be set to true by the user either).

This makes it very easily to add a schema with an error that is silently ignored.

In my case I made a typo with additionalProperties in a fastify response schema, which meant that additional properties were not removed from a response on serialisation that should have been.

It would seem like having strictSchema:true would be a better default? (which would be a breaking change needing a major version I suppose), or at least allow the user to set this.

I tested setting strictSchema:true and running the tests, and the only additional keyword used internally seems to be kind1,2, which is only used in tests.

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 a pull request may close this issue.

1 participant