OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.63k stars 6.53k forks source link

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

Open martin-amaya-appdirect opened 8 months ago

martin-amaya-appdirect commented 8 months ago
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
MarBode commented 8 months ago

i tried to reproduce the error with the cli version 7.2 and 7.3. Both generated correct code for me

/**
   * List all pets
   * 
   * @param companyUuid  (required)
   * @param userUuid  (required)
   * @param includeCompanies  (optional)
   * @return Call&lt;ListPets200Response&gt;
   */
  @GET("{companyUuid}/memberships/{userUuid}")
  Call<ListPets200Response> listPets(
    @retrofit2.http.Path("companyUuid") String companyUuid, @retrofit2.http.Path("userUuid") String userUuid, @retrofit2.http.Query("includeCompanies") Boolean includeCompanies
  );

maybe you can provide your spec or a more detail example i hope it has nothing to do with the gradle build