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

Wrong parameter and method names generated for single quoted properties containing @ sign

Open jgrabowski opened this issue 7 years ago • 1 comments

Description

Codegen on swaggerhub generates Jersey and Resteasy code that doesn't compile when properties contain '@' sign. Codegen generates improper Java fields. Eg. for '@baseType' swagger property definition there is @BaseType field name generated, and also getter/setter names are broken.

Swagger-codegen version

Not sure. The one from swagger.io.

Swagger declaration file content or url

I came across this issue while trying to implement TMF 655 Swagger API: https://raw.githubusercontent.com/tmforum-apis/TMF655_ChangeManagement/master/Change_Management.admin.swagger.json.

properties:
   '@baseType':
          type: string
          default: 'Attachment'
          description: The base type for use in polymorphic collections
Command line used for generation

Not applicable. I was using online codegen from swagger.io. I'll make tests on "standalone" version soon.

Steps to reproduce

Export -> Server stub -> jaxrs-jersey or jaxrs-resteasy

Related issues/PRs
Suggest a fix/enhancement

Codegen should "sanitize" such property names and exclude not allowed chars from field and getter/setter names. @JsonProperty annotation should be sufficient to reflect swagger contract for such properties. I'll try to make a fix in codegen and post my solution soon.

jgrabowski avatar Dec 19 '18 13:12 jgrabowski

It looks like it's already been fixed in master branch but it doesn't work for OpenAPI 3.0. Version from branch 3.0.0 still has described issue.

jgrabowski avatar Dec 19 '18 15:12 jgrabowski