Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][Kotlin][WebClient] Using String templates for path causes incorrect URI variables resolution #16923

Open
5 of 6 tasks
dwawrzyniak1 opened this issue Oct 27, 2023 · 2 comments · May be fixed by #20750
Open
5 of 6 tasks

Comments

@dwawrzyniak1
Copy link

dwawrzyniak1 commented Oct 27, 2023

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

The current implementation of the Kotlin jvm-web-client templates URI variables into a path using a String template instead of a URI builder. That makes micrometer metrics be aggregated by, for example, /person/id/1234 instead of person/id/{id}.

openapi-generator version

7.0.0

OpenAPI declaration file content or url

Anything with URI variables.

Generation Details
openApiGenerate {
  val packageName = "org.example"
  generatorName.set("kotlin")
  library.set("jvm-spring-webclient")
  inputSpec.set(tasks.generateOpenApiDocs.flatMap { it.outputFile })
  outputDir.set("$buildDir/generated/open-api-client")
  this.packageName.set(packageName)
  apiPackage.set("$packageName.api")
  modelPackage.set("$packageName.model")
  configOptions.set(
    mapOf(
      "serializationLibrary" to "jackson",
      "dateLibrary" to "java8",
      "useSpringBoot3" to "false",
      "enumPropertyNaming" to "UPPERCASE"
    )
  )
  importMappings.set(
    mapOf(
      "Pageable" to "org.springframework.data.domain.Pageable"
    )
  )
}
Steps to reproduce

Make the API call with the generated client from an application with a micrometer configured and check out client metrics.

Related issues/PRs

spring-projects/spring-framework#22371

Suggest a fix

Adjust templates to use the UriBuilder instead of String templating.

@wing328
Copy link
Member

wing328 commented Nov 5, 2023

Adjust templates to use the UriBuilder instead of String templating.

I wonder if you can file a PR with the suggested fix. Let me know if you need any help.

@stefankoppier
Copy link
Contributor

@dwawrzyniak1 I'll give this a look. I'm encountering a different bug with double url encoding, which can also be resolved by using UriBuilder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants