seamapi / edgespec

☃️ an API framework for everywhere.
MIT License
5 stars 2 forks source link

Route type generation uses final parsed type of Zod schema rather than input type #98

Closed codetheweb closed 8 months ago

codetheweb commented 8 months ago

If your route spec is:

withRouteSpec({
  queryParams: z.object({
    filter: z.string().transform(s => s.split(","))
  })
})

edgespec will write the type as

{
  queryParams: {
    filter: string[]
  }
}

instead of the correct

{
  queryParams: {
    filter: string
  }
}

Zod provides z.input<typeof schema> for this use case when using types. There's also a _input property available on schemas that seems to be the same thing as a value.