Skip to content

[JAXRS-CXF] Enum values are generating " stuff in the string #3735

@coding2012

Description

@coding2012

The code generator is creating """ still in the jaxrs-cxf implementation:

Example:

public enum TelecomTypeEnum {
      TELEPHONE(String.valueOf(""TELEPHONE"")), FAX(String.valueOf(""FAX"")), EMAIL(String.valueOf(""EMAIL"")), PAGER(String.valueOf(""PAGER""));
    public static TelecomTypeEnum fromValue(String v) {
        return valueOf(v);
    }
}

The Javadoc of the valueOf method is:
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Swagger-codegen version

2.2.1

Swagger declaration file content or url

Example JSON Swagger

    "Telecom": {
            "type": "object",
            "properties": {
                "telecomType": {
                    "type": "string",
                    "enum": [
                        "TELEPHONE",
                        "FAX",
                        "EMAIL",
                        "PAGER"
                    ]
                },
Command line used for generation

mvn clean install using the following plugin:

<build>
        <plugins>
            <plugin>
                <groupId>io.swagger</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${basedir}/src/main/resources/${project.artifactId}-swagger.json</inputSpec>
                            <language>jaxrs-cxf</language>
                            <configOptions>
                                <sourceFolder>/</sourceFolder>
                                <dateLibrary>joda</dateLibrary>
                            </configOptions>
Steps to reproduce

Clone this repo:
https://github.com/coding2012/swagger-codegen-issue-3735

Install latest maven 3, run
mvn clean install

Check folder:
target/generated-sources/swagger/com/test/model/Test.java

This file shows the &quot;

Related issues

This might be somewhat related, but not sure. The fix in this issue missed the jaxrs-cxf codegen code I think:
#3450

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions