phiz71 / vertx-swagger

Swagger integration in Eclipse Vert.X world. A dynamic Vert.X router, configured with a swagger file and a swagger-codegen plugin to generate a server stub.
Apache License 2.0
86 stars 35 forks source link

Enum Model generation is broken #74

Closed codersam closed 7 years ago

codersam commented 7 years ago

Hi,

I have problem generating model files which contains enums. I used swagger-codegen 2.2.3 via gradle plugin.

It is currently also reproducible at http://editor.swagger.io/

Steps to reproduce:

  1. Add enum model definition to API, e.g.:
    ErrorCode:
    type: string
    enum:
      - "REQUIRED_RESOURCE_ID_NOT_SET"
      - "REQUIRED_RESOURCE_NOT_FOUND"
      - "ALREADY_EXISTS"
      - "SOMETHING_ELSE"
  2. Generate Server -> java-vertx.
  3. Observer generated file for ErrorCode enum:
    
    package io.swagger.server.api.model;

import java.util.Objects;

public enum ErrorCode { {values=[REQUIRED_RESOURCE_ID_NOT_SET, REQUIRED_RESOURCE_NOT_FOUND, ALREADY_EXISTS, SOMETHING_ELSE], enumVars=[{name=REQUIRED_RESOURCE_ID_NOT_SET, value="REQUIRED_RESOURCE_ID_NOT_SET"}, {name=REQUIRED_RESOURCE_NOT_FOUND, value="REQUIRED_RESOURCE_NOT_FOUND"}, {name=ALREADY_EXISTS, value="ALREADY_EXISTS"}, {name=SOMETHING_ELSE, value="SOMETHING_ELSE"}]}, }



Kind regards,
Alex
phiz71 commented 7 years ago

Hi, I solve the problem. A problem with a template...

However, you're using the java-vertx generator included into swagger-codegen 2.3.0. So I've also add a PR to fix it : https://github.com/swagger-api/swagger-codegen/pull/6428

codersam commented 7 years ago

Thank you very much for very quick fix. Unfortunately I had no possibility to test it yet, as we decided to do current project without generation. But in next projects I will revisit this plugin for sure.