Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #10164
Closed
Open
Issue created Aug 16, 2021 by Administrator@rootContributor3 of 6 checklist items completed3/6 checklist items

[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.

Assignee
Assign to
Time tracking