Skip to content

Commit bbc0b4a

Browse files
[kotlin-client][jvm-spring-restclient] Fix metrics URI templating for RestClient (#21149)
Spring configures uriTemplate attribute and not generated code
1 parent f954947 commit bbc0b4a

File tree

3 files changed

+6
-6
lines changed
  • modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-spring-restclient/infrastructure
  • samples/client
    • echo_api/kotlin-jvm-spring-3-restclient/src/main/kotlin/org/openapitools/client/infrastructure
    • petstore/kotlin-jvm-spring-3-restclient/src/main/kotlin/org/openapitools/client/infrastructure

3 files changed

+6
-6
lines changed

modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-spring-restclient/infrastructure/ApiClient.kt.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ import org.springframework.util.LinkedMultiValueMap
3636
method(HttpMethod.valueOf(requestConfig.method.name))
3737

3838
private fun <I> RestClient.RequestBodyUriSpec.uri(requestConfig: RequestConfig<I>) =
39-
uri { builder ->
39+
uri(requestConfig.path) { builder ->
4040
builder
41-
.path(requestConfig.path)
4241
.queryParams(LinkedMultiValueMap(requestConfig.query))
4342
.build(requestConfig.params)
4443
}
@@ -50,6 +49,7 @@ import org.springframework.util.LinkedMultiValueMap
5049
when {
5150
requestConfig.headers[HttpHeaders.CONTENT_TYPE] == MediaType.MULTIPART_FORM_DATA_VALUE -> {
5251
val parts = LinkedMultiValueMap<String, Any>()
52+
@Suppress("UNCHECKED_CAST")
5353
(requestConfig.body as Map<String, PartConfig<*>>).forEach { (name, part) ->
5454
if (part.body != null) {
5555
parts.add(name, part.body)

samples/client/echo_api/kotlin-jvm-spring-3-restclient/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ open class ApiClient(protected val client: RestClient) {
3636
method(HttpMethod.valueOf(requestConfig.method.name))
3737

3838
private fun <I> RestClient.RequestBodyUriSpec.uri(requestConfig: RequestConfig<I>) =
39-
uri { builder ->
39+
uri(requestConfig.path) { builder ->
4040
builder
41-
.path(requestConfig.path)
4241
.queryParams(LinkedMultiValueMap(requestConfig.query))
4342
.build(requestConfig.params)
4443
}
@@ -50,6 +49,7 @@ open class ApiClient(protected val client: RestClient) {
5049
when {
5150
requestConfig.headers[HttpHeaders.CONTENT_TYPE] == MediaType.MULTIPART_FORM_DATA_VALUE -> {
5251
val parts = LinkedMultiValueMap<String, Any>()
52+
@Suppress("UNCHECKED_CAST")
5353
(requestConfig.body as Map<String, PartConfig<*>>).forEach { (name, part) ->
5454
if (part.body != null) {
5555
parts.add(name, part.body)

samples/client/petstore/kotlin-jvm-spring-3-restclient/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ open class ApiClient(protected val client: RestClient) {
3636
method(HttpMethod.valueOf(requestConfig.method.name))
3737

3838
private fun <I> RestClient.RequestBodyUriSpec.uri(requestConfig: RequestConfig<I>) =
39-
uri { builder ->
39+
uri(requestConfig.path) { builder ->
4040
builder
41-
.path(requestConfig.path)
4241
.queryParams(LinkedMultiValueMap(requestConfig.query))
4342
.build(requestConfig.params)
4443
}
@@ -50,6 +49,7 @@ open class ApiClient(protected val client: RestClient) {
5049
when {
5150
requestConfig.headers[HttpHeaders.CONTENT_TYPE] == MediaType.MULTIPART_FORM_DATA_VALUE -> {
5251
val parts = LinkedMultiValueMap<String, Any>()
52+
@Suppress("UNCHECKED_CAST")
5353
(requestConfig.body as Map<String, PartConfig<*>>).forEach { (name, part) ->
5454
if (part.body != null) {
5555
parts.add(name, part.body)

0 commit comments

Comments
 (0)