[BUG] [typescript-fetch] Compilation failure in typescript build
Created by: IodizedGabe
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The typescript-fetch
client fails to compile.
Compilation failure:
src/ext/runtime.ts:152:9 - error TS2322: Type '((input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>) | undefined' is not assignable to type '(input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>'.
Type 'undefined' is not assignable to type '(input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>'.
152 return this.configuration.fetchApi;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
openapi-generator version
Version: v5.2.1 Regression: Yes
Generation Details
CLI used:
docker run -v "${PWD}:/local" openapitools/openapi-generator-cli:v5.2.1 generate -i /local/<specfile> -g typescript-fetch
Steps to reproduce
See above
Related issues/PRs
This was introduced in: https://github.com/OpenAPITools/openapi-generator/commit/c05ec99182c80993a218a841853ba6412e6a6c16
This causes an error because this config value may be undefined
:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache#L122
Suggest a fix
The fallback as seen here: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache#L122
Could be added to the getter.