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] ModelNamePrefix is added twice to import statements thereby breaking the build #19039

Open
5 of 6 tasks
ThomasM2204 opened this issue Jun 30, 2024 · 0 comments

Comments

@ThomasM2204
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

When generating the model files the prefix is properly added once in front of the generated files. However, in the import statements the prefix is added twice resulting in erroneous statements breaking the build.

When e.g. SomePrefix is set for modelNamePrefix, then the following model files are generated for example-for-file-naming-option.yaml:

  • SomePrefixPetCategory.ts
  • SomePrefixPet.ts

However, within SomePrefixPet.ts it looks like this:

import type { SomePrefixPetCategory } from './SomePrefixSomePrefixPetCategory';
import {
    SomePrefixPetCategoryFromJSON,
    SomePrefixPetCategoryFromJSONTyped,
    SomePrefixPetCategoryToJSON,
} from './SomePrefixSomePrefixPetCategory';

I.e. SomePrefix is added twice.

openapi-generator version

Issue started in version 7.6.0 and is still there in current master.

Version 7.5.0 is working fine.

OpenAPI declaration file content or url

It can be reproduced using modules/openapi-generator/src/test/resources/3_0/typescript-fetch/example-for-file-naming-option.yaml from the repo:
https://github.com/OpenAPITools/openapi-generator/blob/v7.6.0/modules/openapi-generator/src/test/resources/3_0/typescript-fetch/example-for-file-naming-option.yaml

Generation Details
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
	-i modules/openapi-generator/src/test/resources/3_0/typescript-fetch/example-for-file-naming-option.yaml \
	-g typescript-fetch \
	--additional-properties modelNamePrefix=SomePrefix \
	-o generator_out/
Steps to reproduce

See command above

Related issues/PRs

Nothing found.

Suggest a fix

It's probably due to this PR which touched a bit of relevant code between 7.5.0 and 7.6.0: #18284

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

1 participant