ecyrbe / zodios

typescript http client and server with zod validation

Home Page:https://www.zodios.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: o.status is not a function

aspdev91 opened this issue · comments

Has anyone run into this bug/error when adding a body parameter to an API?

TypeError: o.status is not a function\n' +
    '    at b (/Users/mt/project/app/server/node_modules/@zodios/express/lib/index.js:12:2221)\n' 
    
    makeApi([
  {
    method: 'post',
    path: '/',
    alias: 'getRoutine',
    description: 'Get a specific routine instance by UUID',
    parameters: [
      {
        name: 'body',
        schema: z.object({uuid: z.string()}),
        type: 'Body',
      },
    ],
    response: UserRoutineResponseSchema,
  },
  ])

Seems like an issue with this line:

https://github.com/ecyrbe/zodios-express/blob/f4f6c45eb99814fa74309bfae012c100352cc1a5/src/zodios.ts#L118

I tried logging the parameters in the minified code:

function b(t,e,o,a){o.status(400).json(t);}

and t,e,o,a do not line up with the function parameter signature in the code. When I change the code above to:

function b(t,e,o,a){o()}

it works. "o" is next and any errors parsing against the zod schema are passed to an error middleware I use.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.