Hello,

I defined some String enums in my swagger file and generated server side 
code (Jax-RS) out of it. The "swagger eums" are generated as Java enums, 
for example:

/**
 * Gets or Sets status
 */
public enum StatusEnum {
  PLANED("planed"),

  STARTED("started"),

  FINISHED("finished");

  private String value;

  StatusEnum(String value) {
    this.value = value;
  }

  @Override
  public String toString() {
    return String.valueOf(value);
  }
}


During serialization *toString() *is not used, instaed of the name of the 
enum constant is used. But that is not correct because the enum constant is 
always in upper case and only the string value contains the same writing as 
it is defined in the swagger file. 
As a workaround I annotated the *toString()*-method with *JsonValue*:

@JsonValue
@Override
public String toString() {
  return String.valueOf(value);
}


But always when I re-generate the code or some new enums are added, I have 
to place the *JsonValue* annotation. Is there also another possibility so I 
do not have to manipulate the generated code? Or is it a bug during code 
generation?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to