swagger-api / swagger-api/swagger-codegen
[JAVA] [RESTTEMPLATE] import-mappings does not rename classes inside generated class
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I had to use one API which uses Geolatte in model classes. When I generate code I'll get many classes that does not exist in source project. For example GeometryobjectDTO is generated. That includes many classes that are unusable, for example PositionSequenceDTO.
Best option is to skip generation of those extra classes and use Geolatte classes instead. Import mappings option didn't do that trick for me.
Same json generated working for typescript.
Swagger-codegen version
2.2.3 and 2.3.1
Swagger declaration file content or url
https://gist.github.com/llaocto3/becf5041525b0d2cff51e4046468c25e
Command line used for generation
swagger-codegen-cli generate -i http://localhost:80/v2/api-docs -o /tmp/pettest -l java -D library=resttemplate --model-name-suffix=DTO --import-mappings GeometryobjectDTO=org.geolatte.geom.Geometry,PositionDTO=org.geolatte.geom.Position
Steps to reproduce
- Download spring boot server example from swagger-codegen project
- To model Pet add these lines:
@JsonProperty("geometry")
private Geometry<?> geometry;
@JsonProperty("position")
private Geometry<Position> position;
- Add also import for Geolatte
import org.geolatte.geom.Geometry;
import org.geolatte.geom.Position;
- Compile and run
- Generate with command given in above section
Related issues/PRs
Didn't find any related issues.
Suggest a fix/enhancement
When given different names in mapping classes, rename also the class inside model.
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
Reproduce the issue with the supplied swagger-codegen-cli command, the linked Swagger declaration, and the Java RESTTemplate generator. Inspect the generated GeometryobjectDTO and PositionDTO model references; done means import mappings cause the generated model to use Geolatte Geometry and Position without generating unusable replacement classes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100