zodios: z.transform() on errors
Hello,
It’s look like the transform method is not called when coming from errors calls.
For example
makeEndpoint({
alias: 'updateConfig',
description: 'Modify configuration parameters.',
method: 'put',
path: '/api/:apiKey/config',
response: writableConfigSchema,
parameters: [
parameters.apiKey,
{
name: 'body',
type: 'Body',
schema: writableConfigSchema,
},
],
errors: [
{
status: 400,
description: 'OK: Request succeded.',
schema: z.unknown().transform((foo) => {
console.log(foo)
return foo
}),
},
],
// getErrors(400, 403), // TODO check code with errors code
}),
The console.log is not called and I get a AxiosError exception with status:400 so it’s should work right ?
Thanks
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (16 by maintainers)
I prefer not. It’s a simple one line find. It should not be an issue to duplicate this on your code.
Hello,
Thank you for the report, but this behaviour is normal. There is no way to do transforms on a failing schema or response error. If you need to transform errors, use zodios plugins