I did a test with the latest master and `java` (default: okhttp-gson) but 
couldn't repeat the issue. Here is what the generated code looks like:

  /**

   * platform

   */

  public enum PlatformEnum {

    @SerializedName("darwin")

    DARWIN("darwin"),


    @SerializedName("linux")

    LINUX("linux"),


    @SerializedName("windows")

    WINDOWS("windows");

If you need further help with swagger codegen, I would recommend you 
opening a ticket via https://github.com/swagger-api/swagger-codegen/issues

William

Aki Yoshida於 2017年2月20日星期一 UTC+8下午11時08分37秒寫道:
>
> Hi,
> I am getting invalid code generated for the enum type when using 
> codegen-2.2.2-SNAPSHOT for java. I am not sure if this is an issue or a 
> known issue.
>
> I have a type defined as
> ...
>      "platform":
>          type: "string"
>          description: "platform"
>          enum:
>          - "darwin"
>          - "linux"
>          - "windows"
>
> (I posted a small test yaml at http://pastebin.com/10C3D8RR)
>
> and the generated code for PlatformEnum when using the current codegen- 
> 2.2.2-SNAPSHOT contains the below code fragment
>
> public enum PlatformEnum {
>   @SerializedName(""darwin"")
>   DARWIN(""darwin""),
>
>   @SerializedName(""linux"")
>   LINUX(""linux""),
>
>   @SerializedName(""windows"")
>   WINDOWS(""windows"");
>
>   private String value;
>
>   StatusEnum(String value) {
>     this.value = value;
>   }
> ...
>   }
> ...
>   @Override
>   public String toString()  {
>     StringBuilder sb = new StringBuilder();
>     sb.append("class Version {\n");
>     
>     sb.append("    version: 
> ").append(StringUtil.toIndentedString(version)).append("\n");
>     sb.append("    buildTime: 
> ").append(StringUtil.toIndentedString(buildTime)).append("\n");
>     sb.append("    gitCommit: 
> ").append(StringUtil.toIndentedString(gitCommit)).append("\n");
>     sb.append("    platform: 
> ").append(StringUtil.toIndentedString(platform)).append("\n");
>     sb.append("}");
>     return sb.toString();
>   }
>
>
> In the above, StatusEnum got somehow generated within PlatformEnum type 
> instead of PlatformEnum. This code also contains the code referring to the 
> StringUitl.toIndentedString method which does not exist.
>
> When using codegen-2.2.1, this enum type is correctly generated.
>
> I wanted to use 2.2.2-SNAPSHOT because I was getting from codegen-2.2.1's 
> maven-plugin version the test dependency issue (I had to set compile-scope 
> dependency to junit in my project instead of test-scope to get the code 
> built). And since codegen-2.2.2-SHAPSHOT's maven-plugin version didn't seem 
> to have this issue, I wanted to use it. But I am getting the above issue.
>
> I would appreciate for some help.
>
> Thank you.
>
> regards, aki
>
>
>

-- 
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