swagger-api / swagger-api/swagger-codegen
[JAVA, SPRING] change name of generated class to existing one
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
To reference an existing class during generation the parameter --import-mappings can be used. However this is only working if the component name from your yaml-specification is the same as the class name you reference.
Swagger-codegen version
3.0.33
Suggest a fix/enhancement
It would be great if u could use the --type-mappings parameter to rename the class name and use it additional to the --import-mappings where you specifiy the import for the class.
Example:
If Im forced to use an existing specification which cant be touched, i could define another class with another name as implementation - e.g:
Component in Specification-file:
...
components:
schemas:
PatchComponent:
type: object
...
and then via --type--mappings changeing the name from PatchComponent to JsonMergePatch
and via --import-mappings from your model package changed to javax.json.JsonMergePatch for PatchComponent
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 by reproducing generation from the shown OpenAPI schema with --type-mappings and --import-mappings on swagger-codegen 3.0.33. Trace how the PatchComponent name is resolved for Java/Spring generation; done means an existing javax.json.JsonMergePatch class can be referenced while the generated model name is changed without generating a duplicate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100