Open wembleyoz opened 2 months ago
We are also running in to this issue. Tried the above but we also get the errors in the createApiClient
function and the const endpoints = makeApi
.
Our only workaround I think right now is to group the endpoints. Any other guidance would be appreciated.
We are also running in to this issue. Tried the above but we also get the errors in the
createApiClient
function and theconst endpoints = makeApi
.Our only workaround I think right now is to group the endpoints. Any other guidance would be appreciated.
You can just replace the variable apiClient with
export const apiClient: ZodiosInstance<typeof endpoints> = new Zodios(endpoints);
We are also running in to this issue. Tried the above but we also get the errors in the
createApiClient
function and theconst endpoints = makeApi
. Our only workaround I think right now is to group the endpoints. Any other guidance would be appreciated.You can just replace the variable apiClient with
export const apiClient: ZodiosInstance<typeof endpoints> = new Zodios(endpoints);
not for us, it just shifts the same error to the const endpoints
line....
Read before opening
Describe the bug When generating the client from a large OpenAPI schema, such as the one at LCU OpenAPI schema, the following TypeScript error is encountered:
The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.
The error seems to occur due to the size and complexity of the generated schema and type inference limits in TypeScript.
Minimal reproduction
Expected behavior I expect the generated code to either handle larger schemas gracefully or suggest adding explicit type annotations to avoid the TypeScript inference error. The code should look like the example provided, which avoids importing large objects directly and instead exports each schema individually.
Additional context
Suggested improvement Instead of importing large schemas as a whole (schemas = {...all_schemas}), export individual schemas to avoid the same issue with TypeScript’s type inference limits.
Schematic example of the suggested code change: