Enumeration not working for case sensitive values
Hi @wing328 , I am using swagger stable version 2.1.5 for java client code generator. In my case server expecting values as case sensitive whereas swagger not able to generate case sensitive values for enum. Please find below scenario details:
Below is the sample swagger specification for my newPet model which consist of enum as case sensitive:
newPet: type: object required: - name properties: id: type: integer format: int64 name: type: string Status: type: string enum: [Success, Failure] tag: type: string
While generating java client codegen using Swagger 2.1.5, below enum code getting generated in my model:
`public enum StatusEnum { @SerializedName("Success") SUCCESS("Success"),
@SerializedName("Failure") FAILURE("Failure");
private String value;
StatusEnum(String value) { this.value = value; }
@Override public String toString() { return value; } }`
Then I set enum value into the request as
StatusEnum.SUCCESS
whereas it is expecting as
StatusEnum.Success
Because of this server throwing exception as its expecting value as case sensitive. Please let me know if you require any more input on this or any sample code.
@wing328 .. from where I will get change-log for codegen V 2.1.6?
@sbelan see here: https://github.com/swagger-api/swagger-codegen/releases/tag/v2.1.6
thanks @fehguy
@sbelan it should be fixed by https://github.com/swagger-api/swagger-codegen/pull/3531. Please pull the latest master to give it a try.
@wing328 @fehguy Thanks for the fix. I will check. :+1: I have one proposal for enhancement, Will it be possible to have String Template instead of mustache, as those are much better than mustache templates.
Please open a new issue about your suggestion to use the "String" template so that the community can also join the discussion.
We used to use STL and found it impossible to get contributions to the library so I don't expect we would go back to it
Hi.
I see the ENUM conversion is hardcoded to use .equals. Is it possible to configure it to use .equalsIgnoreCase ?
At least this should be configurable