Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [typescript-fetch] Compilation failure in typescript build #10164

Open
3 of 6 tasks
IodizedGabe opened this issue Aug 16, 2021 · 2 comments
Open
3 of 6 tasks

[BUG] [typescript-fetch] Compilation failure in typescript build #10164

IodizedGabe opened this issue Aug 16, 2021 · 2 comments

Comments

@IodizedGabe
Copy link

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: c05ec99

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.

@wing328
Copy link
Member

wing328 commented Aug 17, 2021

@IodizedGabe can you please submit a PR with the suggested fix? Thanks..

@javier-garcia-meteologica
Copy link
Contributor

#10216 should fix this issue, I think this issue can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants