Skip to content

[JAXRS-CXF] Standalone enum classes are missing class name, data type, and imports #3859

@waltwood

Description

@waltwood
Description

I'm trying to use an enum as a stand-alone class to be used in multiple places in my data model. However the enum classes are not generated correctly and are therefore unusable.

The classes appear to be missing:

  • class name
  • import statements for the JAXB annotations
  • data type for field, constructor, and enum declarations

Example:

package io.swagger.model;

@XmlType(name="")
@XmlEnum
public enum  {

    CAT(.valueOf("cat")), DOG(.valueOf("dog")), FISH(.valueOf("fish"));

    private  value;

     ( v) {
        value = v;
    }

    public String value() {
        return value;
    }

    public static  fromValue(String v) {
        return valueOf(v);
    }
}
Swagger-codegen version

2.2.1

I also pulled the latest code on master (at the time of this report) to see if the problem described here was fixed, but I'm still seeing the behavior.

Swagger declaration file content or url

https://gist.github.com/waltwood/e016cb33c95b78c5a3cf77f264e5c76d#file-petstore-enum-json

Command line used for generation
/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -l jaxrs-cxf -i petstore-enum.json -o temp
Steps to reproduce

Using the example petstore-enum.json definition (linked above), run the codegen via the cli with language of jaxrs-cxf and observe the generated PetType.java enum class file.

Related issues

The following seems somewhat related:
#3735

Suggest a Fix

I believe the issue to be in the mustache templates, but I'm not familiar with the syntax.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions