jlalmes / trpc-openapi

OpenAPI support for tRPC 🧩
https://www.npmjs.com/package/trpc-openapi
MIT License
2.21k stars 153 forks source link

Nested object in input #454

Open RakeshPotnuru opened 1 month ago

RakeshPotnuru commented 1 month ago

Hi, nested object in input for GET method not working.

Example:

getAll: protectedProcedure
    .meta({
      openapi: {
        method: "GET",
        path: "/something/get-all",
        protect: true,
      },
    })
    .input(
      z.object({
        pagination: z.object({ // <--- Error: Input parser key: "pagination" must be ZodString, ZodNumber, ZodBoolean, ZodBigInt or ZodDate
          page: z.number().int().positive().default(1),
          limit: z.number().int().positive().default(10),
        }),
      }),
    )
tristanz commented 1 month ago

This is documented in the readme, but I agree it would be nice to try to have a mapping. These become query parameters, so you'll need to define a mapping to path.