OpenAPITools / OpenAPITools/openapi-generator

[BUG][Typescript Angular] Broken imports with modelSuffix

Open
#13,883 0 comments 9 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

The import paths of models are broken when the option --modelSuffix is used.

// Generated e.g. with v6.2.1

import { InlineResponse200178MyTestApi } from '../model/inlineResponse200178MyTestApi'; // broken

But the file ../model/inlineResponse200178MyTestApi doesn't exists. The file name has no suffix.

//Generated with v7.0.0 (openapi-generator-cli-7.0.0-20221012.083708-4.jar)

import { InlineResponse200178MyTestApi } from '../model/inlineResponse200178'; // expected

Since you already fixed it in the new major version is there any chance that this bug could be fixed also in 6.x?

openapi-generator version

All versions >= 5.2 and < 7.0.0

OpenAPI declaration file content or url

Reproducible e.g. with https://app.swaggerhub.com/apis/binance_api/BinanceSpotAPI/1.0#/Market/get_api_v3_trades

Generation Details
$ openapi-generator-cli generate -i binance_api-BinanceSpotAPI-1.0-resolved.json -g typescript-angular -o my-test-api/src --additional-properties apiModulePrefix=MyTest,configurationPrefix=MyTestApi,enumNameSuffix=MyTestApi,modelSuffix=MyTestApi,serviceSuffix=MyTestApiService --global-property skipFormModel=false
Steps to reproduce

Generate the linked api with the command above and check the imports in e.g. the file convert.service.ts.

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

Run the provided openapi-generator-cli command against the BinanceSpotAPI specification and inspect imports in convert.service.ts alongside the generated model filenames. Compare the typescript-angular output with and without modelSuffix, then confirm that every generated model import resolves to an existing file, including the 6.x output.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.