Skip to content

[BUG] Dart Dio Enum names common prefix shortened #15667

Description

@zaidkazi

Bug Report Checklist

  • [yes] Have you provided a full/minimal spec to reproduce the issue?
  • [yes ] Have you validated the input using an OpenAPI validator (example)?
  • [ yes] Have you tested with the latest master to confirm the issue still exists?
  • [ yes] Have you searched for related issues/PRs?
  • [yes ] What's the actual output vs expected output?
Description
openapi-generator version

openapi-generator-cli 6.6.0

OpenAPI declaration file content or url
    ChangeTempPassword:
      type: object
      properties:
        message:
          type: string
        status:
          type: string
          enum: [ "TEMP_PASSWORD_CHANGED",  "TEMP_PASSWORD_CHANGE_FAILED"]
Generation Details

enum in line json serializable template

{{#enumName}}
    {{#description}}/// {{{description}}}{{/description}}
    {{#isDeprecated}}
        @Deprecated('{{{enumName}}} has been deprecated')
    {{/isDeprecated}}
    enum {{{ enumName }}} {
    {{#allowableValues}}
        {{#enumVars}}
            @JsonValue({{#isString}}r{{/isString}}{{{value}}})
            {{{name}}},
        {{/enumVars}}
    {{/allowableValues}}
    }
{{/enumName}}

is producing


    enum ChangeTempPasswordStatusEnum {
            @JsonValue(r'TEMP_PASSWORD_CHANGED')
            CHANGED,
            @JsonValue(r'TEMP_PASSWORD_CHANGE_FAILED')
            CHANGE_FAILED,
    }


It seems common prefix 'TEMP_PASSWORD' of enum are chopped off but I do not want this behaviour I would like the keep the constant variable name the same as the json value

Suggest a fix

There should be a setting to use full names withut reducing prefix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions