turkerdev / fastify-type-provider-zod

MIT License
303 stars 19 forks source link

The response is typed and accepts unknown keys #63

Closed kevbook closed 10 months ago

kevbook commented 10 months 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 10 months ago

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

image

kevbook commented 10 months ago

Thank you sir!

thelinuxlich commented 9 months ago

Same problem still image