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
Describe the bug
It seems that the JSON schema given to .route() is purely informational despite what the documentation suggests:
.route()
const router = createRouter().route({ method: 'POST', path: '/greetings', schemas: { request: { json: { type: 'object', properties: { name: { type: 'string' }, }, required: ['name'], }, }, }, handler: async (request) => { const { name } = await request.json(); console.log(typeof name); // Should print "string" according to TypeScript return Response.json({ hello: name }); }, });
Running the following code will not return a server error:
fetch('http://localhost:3000/greetings', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: '{}', })
To Reproduce Steps to reproduce the behavior:
https://stackblitz.com/edit/stackblitz-starters-zhnkw4?file=index.ts
Run yarn fetch in another terminal :
yarn fetch
Expected behavior
I'm expecting the request to fail with a 400 Bad Request error
Environment:
Additional context
The text was updated successfully, but these errors were encountered:
I'm pretty sure it's related to #799 and #896
Sorry, something went wrong.
I don't think this is related to those issues. It seems TypeBox validation doesn't work with regular JSON schemas.
But I'm getting the same issues, even when using the 1:1 JSON schema for params from the docs:
No branches or pull requests
Describe the bug
It seems that the JSON schema given to
.route()
is purely informational despite what the documentation suggests:Running the following code will not return a server error:
To Reproduce Steps to reproduce the behavior:
https://stackblitz.com/edit/stackblitz-starters-zhnkw4?file=index.ts
Run
yarn fetch
in another terminal :Expected behavior
I'm expecting the request to fail with a 400 Bad Request error
Environment:
Additional context
The text was updated successfully, but these errors were encountered: