Skip to content

bug in java code generation for Enumeration in swagger document #1176

Description

@MeghaPunj

For java code generation from swagger, for enums, there is a bug in code generation.
I have tried many versions so far but no luck. To replicate the issue, please take the latest stable version or this:

<swagger.codegen.version>3.0.45</swagger.codegen.version>
I have already added under properties:
<errorOnUnknownEnum>true</errorOnUnknownEnum>

The code generated has:

"Unexpected value '" + text + "' for 'MyTest' enum."
instead of:
"Unexpected value '" + input+ "' for 'MyTest' enum."

@JsonCreator
    public static TypeEnum fromValue(String input) {
      for (TypeEnum b : TypeEnum.values()) {
        if (b.value.equals(input)) {
          return b;
        }
      }
      throw new IllegalArgumentException("Unexpected value '" + text + "' for 'MyTest' enum.");
    }

Also there is mention of this change here:
#713

May be the same is missing in the latest version 3.x.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions