swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[JAVA, SPRING] change name of generated class to existing one

Open JohannesProbst opened this issue 4 years ago • 0 comments

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

JohannesProbst avatar Sep 30 '22 07:09 JohannesProbst