ecyrbe / zodios

typescript http client and server with zod validation
https://www.zodios.org/
MIT License
1.71k stars 46 forks source link

[Feature Request] Validation on path parameters #177

Closed ecyrbe closed 2 years ago

ecyrbe commented 2 years ago

Discussed in https://github.com/ecyrbe/zodios/discussions/176

Originally posted by **epotter2297** October 11, 2022 It would be really cool if there was a way to use zod to validate my path parameters. For example, if I have an endpoint like so: ```js { method: 'get', path: '/users/:id', alias: 'getUser', description: 'Get a user', response: z.object({ id: z.number(), name: z.string().nullable(), }), }, ``` And I want to make sure that `id` is a valid UUID, I could do something like: ```js { method: 'get', path: '/users/:id', alias: 'getUser', description: 'Get a user', parameters: [ { name: 'id', description: 'The user id', type: 'Path', schema: z.string().uuid(), }, ], response: z.object({ id: z.number(), name: z.string().nullable(), }), }, ```
ecyrbe commented 2 years ago

available on zodios v10.0.0