OpenAPITools / OpenAPITools/openapi-generator

[BUG][JAVA] openApiGenerate task using java generator builds interfaces with syntax error: query parameters are not being separated by commas

Open
#17,764 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

When running gradle openApiGenerate task, the generated api interface is created with syntax errors

My build.gradle task:

plugins {
    // openapi docs: https://portrait.gitee.com/petershowx/OpenAPI-Generator/blob/master/modules/openapi-generator-gradle-plugin/README.adoc
    // https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/README.adoc
    id "org.openapi.generator" version "7.2.0"
}

dependencies {
    compileOnly 'org.projectlombok:lombok'
}

openApiGenerate {
    generatorName.set("java")
    inputSpec.set("${projectDir}/swagger-file/account-V2-swagger.yml")
    outputDir.set("${buildDir}/swagger-code")
    apiPackage.set("com.martin.sales.client.account.api")
    modelPackage.set("com.martin.sales.client.account.api.dto")
    modelNameSuffix.set("WS")
    globalProperties.set([
        apis: "",
        models: ""
    ])
    configOptions.set([
        "useSpringBoot3": "true",
        "useJakartaEe": "true"
    ])
    library.set("retrofit2")
    skipOverwrite.set(false)
}

tasks.compileJava.dependsOn('openApiGenerate')

sourceSets.main.java.srcDirs += ["${buildDir}/swagger-code/src/main/java"]

generated code:

public interface AccountApi {
  /**
   * Returns the details of a user/company membership
   * 
   * @param companyUuid The uuid of the company (required)
   * @param userUuid The uuid of the user (required)
   * @param includeCompanies Indicates if the companies must be included in the response (optional)
   * @return Call<UserCompanyMembershipWS>
   */
  @GET("{companyUuid}/memberships/{userUuid}")
  Call<UserCompanyMembershipWS> readCompanyMembership(
    @retrofit2.http.Path("companyUuid") String companyUuid
  );@retrofit2.http.Path("userUuid") String userUuid
  );@retrofit2.http.Query("includeCompanies") Boolean includeCompanies
  );
}
openapi-generator version

"7.2.0"

OpenAPI declaration file content or url

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue provides an inline OpenAPI declaration and a Gradle openApiGenerate reproduction; start by running gradle clean openApiGenerate with the Java retrofit2 generator. Compare the generated AccountApi signature with the reported output, and verify that the generated Java interface compiles with comma-separated parameters.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.