I am trying to create an API using Swagger 2.0. I would like to generate an interactive documentation using SwaggerUI and also generate API clients (in Java, JavaScript...). I just tried to generate a small Java Client.
I have a problem with Enumerations... In Swagger I can write the following (YAML here, the problem is the same if directly writing JSON):
definitions:
MediumStatus:
type: string
enum:
- CLOSED
- OPEN_AVAILABLE
- OPEN_NOT_AVAILABLE
- NOT_AVAILABLE
In the generated Java Client, what is expect/want is something like:
public enum MediumType
{
CLOSED,
OPEN_AVAILABLE,
OPEN_NOT_AVAILABLE,
NOT_AVAILABLE;
public String value()
{
return name();
}
public static MediumType fromValue(String v)
{
return valueOf(v);
}
}
but the SwaggerCodegen generate a client with:
@ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-21T14:03:23.470Z")
public class MediumType {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class MediumType {\n");
sb.append("}");
return sb.toString();
}
}
This class is not really correct, it don't even contains the enum values !
Can someone can tell me what I am missing ?
EDIT/
Problem sovlded with https://github.com/swagger-api/swagger-codegen/pull/1740