turkerdev / fastify-type-provider-zod

MIT License
413 stars 25 forks source link

The response is typed and accepts unknown keys #63

Closed kevbook closed 1 year ago

kevbook commented 1 year ago

I tried with strict() and without strict(). Anyone can help?

  fastify.withTypeProvider<ZodTypeProvider>().post(
    '/person',
    {
      schema: {
        body: z.object({ a: z.string() }),
        response: { '2xx': z.object({ b: z.string() }).strict() },
      },
    },
    function (request, reply) {
      console.log(request.body.a); // Typed
      return { b: '9', c: 1 }; // Typed but accepts c
    }
  );
turkerdev commented 1 year ago

res.send()/reply.send() method works fine. i recommend using it.

image

kevbook commented 1 year ago

Thank you sir!

thelinuxlich commented 1 year ago

Same problem still image