Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAX-RS Swagger codegen does not handle enum defined in external json file #4123

Open
abhijith-prabhakar opened this issue Nov 3, 2016 · 1 comment

Comments

@abhijith-prabhakar
Copy link

If an enum is added into external json file Swagger Codegen does not generate model correctly.
Example project: https://github.com/abhijith-prabhakar/swagger-ref-error-demo/blob/master/src/main/resources/v1/schema/title/title.json#L43

 "media_types": {
      "description": "different media types",
      "type": "array",
      "items" : {
        "type" : "string",
        "enum" : [ "application/pdf", "application/json" ]
      }
    },

Generated Code

/**
   * different media types
   */
  public enum List<MediaTypesEnum> {
    PDF("application/pdf"),

        JSON("application/json");
    private List<String> value;

    List<MediaTypesEnum>(List<String> value) {
      this.value = value;
    }

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

omarzina commented Nov 24, 2016

Hi, I'm having same problem i think. Tried generating resteasy server from yaml with:

TaskType:
        type: string
        description: "Tipo de tarea asociada. cancelación, agenda, etc."
        enum:
          - cancelation
          - schedule

with resulting generated enum:

public enum TaskType {
    {values=[cancelation, schedule], enumVars=[{name=CANCELATION, value="cancelation"}, {name=SCHEDULE, value="schedule"}]}, 
}

If I use jaxrs server generator instead of resteasy it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants