Hi, i'm working with Fastify, zod and fastify-zod-openapi. Following the versions:
"fastify": "^5.6.0",
"fastify-zod-openapi": "^5.4.0",
"zod": "^4.1.8"
When i declare a route with in it parameters or queryString object i'm facing the following error:
Type 'ZodObject<{ plantId: ZodString; }, $strip>' is not assignable to type 'ZodObjectInputType'.
Types of property '_zod' are incompatible.
Type '$ZodObjectInternals<{ plantId: ZodString; }, $strip>' is not assignable to type 'Record<string, unknown>'.
Index signature for type 'string' is missing in type '$ZodObjectInternals<{ plantId: ZodString; }, $strip>'.ts(2322)
index.d.ts(124, 5): The expected type comes from property 'params' which is declared here on type 'FastifyZodOpenApiSchema'
Following the zod definition:
export const plantIdParams = z.object({
plantId: z.string()
})
Here the route definition
app.get('/clients/plants/:plantId/roleMappings', {
schema: {
tags: ['Clients'],
summary: 'Clients + roles related to [plantId]',
description: 'Return an array of clients with all roles associated to the [plantId] passed via params',
params: plantIdParams,
response: {
200: {
responseRoleByPlantOA,
description: 'Return an object containing the role list for the give userId'
},
404: { responseError, description: 'PlantId does not exist' },
500: {
responseError,
description: 'Keycloak service account connection error'
}
}
} satisfies FastifyZodOpenApiSchema,
config: { resource: 'plant', scope: 'assign-role' },
preHandler: enforcePlantIdRequest,
handler: composePlantRoleMapping
})
I tried to remove satisfies FastifyZodOpenApiSchema and the error disappear. How can i solve? Thanks
Hi, i'm working with Fastify, zod and fastify-zod-openapi. Following the versions:
When i declare a route with in it parameters or queryString object i'm facing the following error:
Following the zod definition:
Here the route definition
I tried to remove satisfies FastifyZodOpenApiSchema and the error disappear. How can i solve? Thanks