Forum Discussion

ThGkatz's avatar
ThGkatz
New Member
4 years ago

Java definition of Resource property with snake_case is generated to camelCase

Greetings,

 

I'm using the swagger-codegen maven plugin version 2.1.6.

I have a Resource object which needs some properties to be exposed as snake_case. This is required for the communication with an external third party API and cannot change.

 

In my yaml definition I have something like:

ResourceName:

  properties:

    snake_case_property:

      type: string

 

which creates a ResourceName class with the property camelCaseProperty and annotates it with JsonProperty("camelCaseProperty").

 

Is there any way to keep the snake_case? At least in the JsonProperty annotation.

1 Reply

  • Hello,

    No really, Java generators are set to work with camel case, any snake case found will be converted to camel case.

     

    Currently there is not any option to work with both cases.