Skip to content

[BUG][Java] Unable to rename inner enum #20790

@david0

Description

@david0

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When upgrading to OpenAPI 3.1, some enums are generated as inner enums.

It would be very useful to be able to rename them to the old names. Unfortunately this is not possible

openapi-generator version

7.11.0

OpenAPI declaration file content or url
Generation Details
Steps to reproduce

Given these files:

foo.yaml

openapi: 3.0.4
info:
  title: foo API
  version: 0.0.1
paths:
  /foo:
    get:
      responses:
        200:
          description: foo
          content:
            application/json:
              schema:
                $ref: 'user.yml#/Response'

and the shared common.yaml

Response:
  properties:
    id:
      type: integer

Running this will generate two files, one being the shared class:

openapi-generator generate -g java -i foo.yaml

tree src/main/java/org/openapitools/client/model
├── AbstractOpenApiSchema.java
├── Response.java
└── Status.java

But if you foo.yaml to openapi: 3.1.0, FooGet200Response will be generated. This file can be renamed using modelNameMappings

openapi-generator generate -g java  -i foo.yaml --model-name-mappings _foo_get_200_response=Response

tree src/main/java/org/openapitools/client/model
├── AbstractOpenApiSchema.java
└── Response.java

But inside is an Enum, that cannot be renamed:

grep  'enum '  ./src/main/java/org/openapitools/client/model/FooGet200Response.java
  public enum StatusEnum {
Suggest a fix

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