You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My schema contains the query parameter tags which is an array of zero or more values.
However, the problem is that tags is only transformed into an array in req.query if it is used more than once in the url:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I use zod to parse query parameters in Next.JS:
My schema contains the query parameter
tagswhich is an array of zero or more values.However, the problem is that
tagsis only transformed into an array inreq.queryif it is used more than once in the url:I have been able to get around this by using
union:However, this causes
zod-to-openapito produce a schema like this:{ "anyOf": [ { "type": "string", "enum": [ "musician", "songwriter", "instructor", "organizer", "photographer" ] }, { "type": "array", "items": { "type": "string", "enum": [ "musician", "songwriter", "instructor", "organizer", "photographer" ] } } ] }rather than the desired
{ "type": "array", "items": { "type": "string", "enum": [ "musician", "songwriter", "instructor", "organizer", "photographer" ] } }Is there a way to make
zod-to-openapiunderstand that I want the second output?(Why is this important? Because it causes swagger ui to render two different styles of input)
All reactions