We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
4.24.0
2.2.2
18.x
Linux
22
following your example:
const plugin: FastifyPluginAsyncJsonSchemaToTs = async function ( fastify, _opts ) { fastify.get( "/", { schema: { body: { type: "object", properties: { x: { type: "string" }, y: { type: "number" }, z: { type: "boolean" }, }, required: ["x", "y", "z"], } as const, }, }, (req) => { /// The `x`, `y`, and `z` types are automatically inferred const { x, y, z } = req.body; } ); };
now req.body has the following type
req.body
{ // extra property that allows arbitrary props that don't exist in the original schema [x: string]: unknown; x: string; y: string; z: string; }
remove the extra prop, and you may add an option to allow arbitrary props
.
No response
The text was updated successfully, but these errors were encountered:
What happens if you do additionalProperties: false
additionalProperties: false
Sorry, something went wrong.
this works, please add this note to the docs. also, I think it may be better to allow additional properties only if it set explicitly to trye
Successfully merging a pull request may close this issue.
Prerequisites
Fastify version
4.24.0
Plugin version
2.2.2
Node.js version
18.x
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
22
Description
following your example:
now
req.body
has the following typeremove the extra prop, and you may add an option to allow arbitrary props
Steps to Reproduce
.
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: