When an operationId is long, the generated endpoint schema is wrapped with z.object(). This happens when the generator is zod. I'm not sure about the others.
As a result, this makes the type errors occur in the methods of ApiClient.
Given an openapi endpoint schema with a very long operationId
/category/{categoryId}:
delete:
operationId: very_very_very_very_very_very_very_very_very_very_long
parameters:
- name: categoryId
in: path
description: Category id to delete
required: true
schema:
type: integer
format: int64
responses:
"400":
description: Invalid category id
The link for the typed-openapi playground can be found here
and I got the type errors inside the ApiClient methods.
Type 'TEndpoint["parameters"]' does not satisfy the constraint 'ZodType<any, any, any>'.
Type '{ "/category/{categoryId}": ZodObject<{ method: ZodLiteral<"DELETE">; path: ZodLiteral<"/category/{categoryId}">; parameters: ZodObject<{ path: ZodObject<{ categoryId: ZodNumber; }, "strip", ZodTypeAny, { ...; }, { ...; }>; }, "strip", ZodTypeAny, { ...; }, { ...; }>; response: ZodUnknown; }, "strip", ZodTypeAny, { ...' is not assignable to type 'ZodType<any, any, any>'.ts(2344)
Type '"parameters"' cannot be used to index type 'TEndpoint'.ts(2536)
Version
0.6.0
Steps to reproduce
When an
operationId
is long, the generated endpoint schema is wrapped withz.object()
. This happens when the generator iszod
. I'm not sure about the others.As a result, this makes the type errors occur in the methods of
ApiClient
.Given an openapi endpoint schema with a very long
operationId
The link for the
typed-openapi
playground can be found hereExpected behavior
The generated endpoint schema should be
Actual behavior
The generated endpoint schema is
and I got the type errors inside the
ApiClient
methods.