OpenAPITools / OpenAPITools/openapi-generator

[BUG] [typescript-axios] Missing import for ActionResult<IDictionary<string, IEnumerable<QueryResponse>>>

Open
#9,385 1 comment 0 reactions 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

When a C# controller action returns ActionResult<IDictionary<string, IEnumerable<QueryResponse>>>
And a web client is generated using the typescript-axios generator
Then the generated implementation of the controller is missing an import to QueryResponse
https://github.com/szszoke/OpenAPIBadTS

Code for QueryResponse is properly generated, it is just not imported.

The relevant file is https://github.com/szszoke/OpenAPIBadTS/blob/main/web_client/api/weather-forecast-api.ts

The same output is generated using the latest docker image, which can be seen my running docker build . in the root directory of the demo repository.

openapi-generator version

5.1.0

OpenAPI declaration file content or url

https://github.com/szszoke/OpenAPIBadTS/blob/main/swagger.json

Generation Details

Minimal project to trigger the bug:

https://github.com/szszoke/OpenAPIBadTS

Steps to reproduce
  1. git clone https://github.com/szszoke/OpenAPIBadTS
  2. cd OpenAPIBadTS
  3. dotnet restore
  4. dotnet build
  5. npm install
  6. npm run trigger-bug

Observe that the last step, where the generated client is compiled via the TypeScript compiler, fails due to the missing import of QueryResponse.

The expected output would be that QueryResponse is imported in api/weather-forecast-api.ts. The actual output is that it is not imported.

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

Clone OpenAPIBadTS and run the listed .NET and npm steps, especially npm run trigger-bug, to reproduce the TypeScript compilation failure. Compare the generated web_client/api/weather-forecast-api.ts with swagger.json and trace the typescript-axios generator's import handling; done means QueryResponse is imported and the generated client compiles.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.