swagger-api / swagger-api/swagger-codegen
--type-mappings option not working correctly anymore since 2.14.12+ - mapped files are still generated
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
The --type-mappings option not working correctly anymore since 2.14.12+ - mapped files are still generated.
until 2.4.11 everything ok:
java -jar swagger-codegen-cli-2.4.11.jar generate -l java -i %SWAGGER% --model-package %MODPKG% --import-mappings MyPet=foo.bar.MyPet
[main] INFO io.swagger.codegen.DefaultGenerator - Model MyPet not imported due to import mapping
and the MyPet class is not generated - as it should be.
since 2.4.12 it breaks:
java -jar swagger-codegen-cli-2.4.12.jar generate -l java -i %SWAGGER% --model-package %MODPKG% --import-mappings MyPet=foo.bar.MyPet
[main] INFO io.swagger.codegen.AbstractGenerator - writing file C:\temp\codegen\some\package\MyPet.java
But it should not be written because of import mapping.
Reason in 2.14.12 - the ignoreImportMapping option was removed by someone - but not completely.
In the interface CodegenConfig.java there is still : boolean getIgnoreImportMapping(); left (and also Boolean getSkipAliasGeneration();) and that is now by default false
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java
Please remove the methods getIgnoreImportMapping(); and getSkipAliasGeneration(); and in all implementing classes also.
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java, then locate its implementing classes and inspect the remaining mapping-related methods. Reproduce the provided Java CLI generation command and verify that the mapped MyPet file is no longer generated after the obsolete methods are removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100