Swagger可以生成Java枚举吗?

时间:2015-09-14 17:28:04

标签: java enums swagger swagger-editor

我有以下Swagger定义,我希望swagger-codegen将生成一个Java Enum类。我已经仔细阅读了swagger论坛,看起来swagger-codegen应该生成正确的Java代码。

"definitions": {
  "AnalystScoreEnum": {
    "type": "string",
    "enum": [
      "POOR",
      "AVERAGE"
    ]
  }
}

swagger-codegen的输出结果如下:

package io.swagger.client.model;

import io.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty;

@ApiModel(description = "")
public class AnalystScoreEnum  {

  @Override
  public String toString()  {
    StringBuilder sb = new StringBuilder();
    sb.append("class AnalystScoreEnum {\n");

    sb.append("}\n");
    return sb.toString();
  }
}

我期待/想要的是以下内容:

public enum AnalystScoresEnum {
  POOR(1),
  AVERAGE(2)

  private int value;
  private AnalystScoresEnum(int value) {
    this.value = value;
  }
  public int getValue() {
    return value;
  }
}

0 个答案:

没有答案