Skip to content

[BUG] [Java] Generated methods have a "_<number>" suffix #19865

@ahoehma

Description

@ahoehma
Description

Since version 7.9.0 my generated java-client looks different. Almost all methods got an additional "_NN" on there names which is breaking my surrounding java code.

openapi-generator version

7.9.0

OpenAPI declaration file content or url
{
  "openapi": "3.0.1",
  "paths": {
     "/api/v1/brain/product/localizations/{productId}/{version}": {
      "post": {
        "tags": [
          "read",
          "service",
          "v1.24"
        ],
        "summary": "Get localization data for a product. This was introduced in 2024.15.0 with api 1.24.",
        "operationId": "getProductLocalizations",
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "description": "Provide the id of the product.",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "1LE1X"
          },
          {
            "name": "version",
            "in": "path",
            "description": "Provide the version of the product. Could be 'LATEST' to retrieve the newest version.",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "LATEST"
          }
        ],
        "requestBody": {
          "description": "Required payload for the request.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GetProductLocalizationsPayload"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetProductLocalizationsResult"
                }
              }
            }
          }
      }
    }
}
...

I can't post the whole definition because of closed source ... but the interesting part is here I hope. It's all about the "operationId": "getProductLocalizations" ... and all the "operationId's" are unique in the openapi.json.

Generation Details
<plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>7.9.0</version>
        <configuration>
          <!-- https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/java.md -->
          <generatorName>java</generatorName>
          <addCompileSourceRoot>true</addCompileSourceRoot>
          <generateModelTests>false</generateModelTests>
          <skipOverwrite>false</skipOverwrite>
          <indentSize>2</indentSize>
          <lineLength>200</lineLength>
          <verbose>false</verbose>
          <skipIfSpecIsUnchanged>false</skipIfSpecIsUnchanged>
          <configOptions>
            <additionalModelTypeAnnotations><![CDATA[ @SuppressWarnings("all") ]]></additionalModelTypeAnnotations>
            <enumUnknownDefaultCase>true</enumUnknownDefaultCase>
            <library>resttemplate</library>
            <java8>true</java8>
            <dateLibrary>java8</dateLibrary>
            <failOnUnknownProperties>false</failOnUnknownProperties>
            <sortModelPropertiesByRequiredFlag>false</sortModelPropertiesByRequiredFlag>
            <sortParamsByRequiredFlag>false</sortParamsByRequiredFlag>
          </configOptions>
        </configuration>
<executions>
<execution>
            <id>generate-apiclient-cc-configuration-brain</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${openapi.input.cerebellum}</inputSpec> <!-- kleinhirn -->
              <output>${project.build.directory}/generated-sources/cc-api-cerebellum</output>
              <apiPackage>com.foo.spice.cc.client.brain.api</apiPackage>
              <modelPackage>com.foo.spice.cc.client.brain.model</modelPackage>
              <invokerPackage>com.foo.spice.cc.client.brain.handler</invokerPackage>
            </configuration>
          </execution>
<executions>
</plugin>

The generated code looks like this:

/**
     * Get localization data for a product. This was introduced in 2024.15.0 with api 1.24.
     * 
     * <p><b>200</b> - OK
     * @param productId Provide the id of the product. (required)
     * @param version Provide the version of the product. Could be &#39;LATEST&#39; to retrieve the newest version. (required)
     * @param getProductLocalizationsPayload Required payload for the request. (required)
     * @return GetProductLocalizationsResult
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public GetProductLocalizationsResult getProductLocalizations_0(String productId, String version, GetProductLocalizationsPayload getProductLocalizationsPayload) throws RestClientException {
        return getProductLocalizations_0WithHttpInfo(productId, version, getProductLocalizationsPayload).getBody();
    }

How to disable this additional suffixes? And why there are even there ? :-)

Kind regards
Andreas

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