-
Notifications
You must be signed in to change notification settings - Fork 40
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
Skip Validation #109
Skip Validation #109
Conversation
🧪 A prerelease is available for testing 🧪 You can install this latest build in your project with: npm install --save https://prerelease-registry.devprod.cloudflare.dev/itty-router-openapi/runs/8122549266/npm-package-itty-router-openapi-109 Or you can immediately run this with npx https://prerelease-registry.devprod.cloudflare.dev/itty-router-openapi/runs/8122549266/npm-package-itty-router-openapi-109 |
Hey @rmzaoo
Did i understand your question right? |
@G4brym I tried that but it didn't work. |
@G4brym Any news about it? |
@rmzaoo for you to receive any parameters in the reques body, you will need to use Zod Catchall export class TestBody extends OpenAPIRoute {
static schema: OpenAPIRouteSchema = {
requestBody: z.object({}).catchall(z.any()),
}
async handle(
request: Request,
env: any,
context: any,
data: any,
) {
return data
}
}
router.post('/test', TestBody) Then you will be able to send any parameters inside the body like this: |
@G4brym Okey perfect, that's good. |
@G4brym Again about skipvalidation, after a few tests the parameters passed in such as path, query and header also do their validation. I would be ok with not merging this change, but, do you have any suggestion to skip it not only for body but for path, query and headers too? |
@rmzaoo sorry for the delay, I'm currently out of the office, I will only be able to merge this early January, meanwhile you can use this branch preview build by running this command |
Is this PR going to be merged? |
I modified the code to skip the parse validation function and allow unknown parameters in the request body. This was done because we couldn’t find any other solution.
Did I miss something in the documentation? Is there a way, with the current implementation, to allow unknown parameters in the request body structure without skipping the parse validation function?