OpenAPITools / OpenAPITools/openapi-generator

[BUG] Typescript Fetch Client Code Fails

Open
#14,975 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

There are couple of issues with the generated code on Windows , The typescript code contains errors

1 - ERROR IN export and import , I pasted the whole folder with tsconfig.json , since generated tsconfig.json is being used , there shouldn't be this error
ERROR in src/api/index.ts:5:10
TS1205: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
    3 | export * from "./models/all";
    4 | export { createConfiguration } from "./configuration"
  > 5 | export { Configuration } from "./configuration"
      |          ^^^^^^^^^^^^^
    6 | export * from "./apis/exception";
    7 | export * from "./servers";
    8 | export { RequiredError } from "./apis/baseapi";

ERROR in src/api/index.ts:10:10
TS1205: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
     8 | export { RequiredError } from "./apis/baseapi";
     9 |
  > 10 | export { PromiseMiddleware as Middleware } from './middleware';
       |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    11 | export { PromiseDefaultApi as DefaultApi } from './types/PromiseAPI';
    12 |
    13 |
Object Serializer Imports in Body of module
[eslint] 
src\api\models\ObjectSerializer.ts
  Line 25:1:  Import in body of module; reorder to top  import/first
  Line 26:1:  Import in body of module; reorder to top  import/first
  Line 27:1:  Import in body of module; reorder to top  import/first
  Line 28:1:  Import in body of module; reorder to top  import/first
  Line 29:1:  Import in body of module; reorder to top  import/first
  Line 30:1:  Import in body of module; reorder to top  import/first
  Line 31:1:  Import in body of module; reorder to top  import/first
  Line 32:1:  Import in body of module; reorder to top  import/first
2 - Error with Backslashes

I don't know if backslashes inside imports work on other operating systems , but they don't work in windows , the backslash is escaping the character and I'm getting an error in IDE

import { Member } from '..\models\Member';
import { ProjectBugsInner } from '..\models\ProjectBugsInner';
import { User } from '..\models\User';
3- How to download the latest master using npm or easily

as I'm using 6.4.0 , which is the latest stable version , If these issues have been fixed in the latest master , I'd like to use that instead but listing the npm version there's no snapshot version there , How can I easily download the latest version

Also the linode server latest uses the older 5.2.0 version which also doesn't work

openapi-generator version

6.4.0

OpenAPI declaration file content or url

any code generated

Generation Details

language : typescript-fetch

Steps to reproduce

1 - Generate code using typescript-fetch

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce generation with the typescript-fetch option and inspect the generated src/api/index.ts, ObjectSerializer.ts, and model import paths on Windows. Check the generated tsconfig.json and run the reported TypeScript and ESLint checks; done means generated code compiles and passes lint without the export, import-order, or backslash errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.