-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
We have an oauth2 token endpoint, and we want it to work both with application/json and application/x-www-form-urlencoded. This does not seem to be possible out of the box.
However, it seems I can do this in roughly this way:
- specifying no
input.contentType - providing a
z.union()forinput.bodywhich accepts a zod schema and a zod-form-data schema - using custom logic in the
handler()to manage content-type and coerce types - provide a
openApiOperation.requestBodyand ignore type errors, the openapi schema reflects the expected structure
Is there a less hacky way to do this? Is this a capability that could be officially supported?
Another side note -- just trying to create a standard form data endpoint using the example from the docs, I get a type error on body: formSchema. This is with next-rest-framework 6.0.7, zod 3.25.76, and sod-form-data 2.0.8. The execution works.
Metadata
Metadata
Assignees
Labels
No labels