From f56588fe55553da6fd11a585bd1ee41a941c41ae Mon Sep 17 00:00:00 2001 From: ghostbuster91 Date: Tue, 7 Jul 2020 22:53:38 +0200 Subject: [PATCH 1/2] Wrap query params with additional curly braces --- .../src/main/resources/scala-sttp/api.mustache | 2 +- .../src/main/scala/org/openapitools/client/api/PetApi.scala | 4 ++-- .../src/main/scala/org/openapitools/client/api/UserApi.scala | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/scala-sttp/api.mustache b/modules/openapi-generator/src/main/resources/scala-sttp/api.mustache index e67b67018c59..f60d2c5afd3f 100644 --- a/modules/openapi-generator/src/main/resources/scala-sttp/api.mustache +++ b/modules/openapi-generator/src/main/resources/scala-sttp/api.mustache @@ -22,7 +22,7 @@ class {{classname}}(baseUrl: String) { {{/javadocRenderer}} def {{operationId}}({{>methodParameters}}): Request[{{#separateErrorChannel}}Either[ResponseError[Exception], {{>operationReturnType}}]{{/separateErrorChannel}}{{^separateErrorChannel}}{{>operationReturnType}}{{/separateErrorChannel}}, Nothing] = basicRequest - .method(Method.{{httpMethod.toUpperCase}}, uri"$baseUrl{{{path}}}{{#queryParams.0}}?{{#queryParams}}{{baseName}}=${{{paramName}}}{{^-last}}&{{/-last}}{{/queryParams}}{{/queryParams.0}}{{#isApiKey}}{{#isKeyInQuery}}{{^queryParams.0}}?{{/queryParams.0}}{{#queryParams.0}}&{{/queryParams.0}}{{keyParamName}}=${apiKey.value}&{{/isKeyInQuery}}{{/isApiKey}}") + .method(Method.{{httpMethod.toUpperCase}}, uri"$baseUrl{{{path}}}{{#queryParams.0}}?{{#queryParams}}{{baseName}}=${ {{{paramName}}} }{{^-last}}&{{/-last}}{{/queryParams}}{{/queryParams.0}}{{#isApiKey}}{{#isKeyInQuery}}{{^queryParams.0}}?{{/queryParams.0}}{{#queryParams.0}}&{{/queryParams.0}}{{keyParamName}}=${apiKey.value}&{{/isKeyInQuery}}{{/isApiKey}}") .contentType({{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}{{^consumes}}"application/json"{{/consumes}}){{#headerParams}} .header({{>paramCreation}}){{/headerParams}}{{#authMethods}}{{#isBasic}}{{#isBasicBasic}} .auth.withCredentials(username, password){{/isBasicBasic}}{{#isBasicBearer}} diff --git a/samples/client/petstore/scala-sttp/src/main/scala/org/openapitools/client/api/PetApi.scala b/samples/client/petstore/scala-sttp/src/main/scala/org/openapitools/client/api/PetApi.scala index 034cceb63cc7..8f541ae7bfe4 100644 --- a/samples/client/petstore/scala-sttp/src/main/scala/org/openapitools/client/api/PetApi.scala +++ b/samples/client/petstore/scala-sttp/src/main/scala/org/openapitools/client/api/PetApi.scala @@ -67,7 +67,7 @@ class PetApi(baseUrl: String) { def findPetsByStatus(status: Seq[String] ): Request[Either[ResponseError[Exception], Seq[Pet]], Nothing] = basicRequest - .method(Method.GET, uri"$baseUrl/pet/findByStatus?status=$status") + .method(Method.GET, uri"$baseUrl/pet/findByStatus?status=${ status }") .contentType("application/json") .response(asJson[Seq[Pet]]) @@ -83,7 +83,7 @@ class PetApi(baseUrl: String) { def findPetsByTags(tags: Seq[String] ): Request[Either[ResponseError[Exception], Seq[Pet]], Nothing] = basicRequest - .method(Method.GET, uri"$baseUrl/pet/findByTags?tags=$tags") + .method(Method.GET, uri"$baseUrl/pet/findByTags?tags=${ tags }") .contentType("application/json") .response(asJson[Seq[Pet]]) diff --git a/samples/client/petstore/scala-sttp/src/main/scala/org/openapitools/client/api/UserApi.scala b/samples/client/petstore/scala-sttp/src/main/scala/org/openapitools/client/api/UserApi.scala index fd3b82392b89..b3a39fea84a1 100644 --- a/samples/client/petstore/scala-sttp/src/main/scala/org/openapitools/client/api/UserApi.scala +++ b/samples/client/petstore/scala-sttp/src/main/scala/org/openapitools/client/api/UserApi.scala @@ -129,7 +129,7 @@ class UserApi(baseUrl: String) { def loginUser(username: String, password: String ): Request[Either[ResponseError[Exception], String], Nothing] = basicRequest - .method(Method.GET, uri"$baseUrl/user/login?username=$username&password=$password") + .method(Method.GET, uri"$baseUrl/user/login?username=${ username }&password=${ password }") .contentType("application/json") .response(asJson[String]) From 4e8e4f250e341d0aef051cb5588a260c3c6383ca Mon Sep 17 00:00:00 2001 From: ghostbuster91 Date: Tue, 7 Jul 2020 22:53:55 +0200 Subject: [PATCH 2/2] Sttp - remove unused file --- .../src/main/resources/scala-sttp/paramQueryCreation.mustache | 1 - 1 file changed, 1 deletion(-) delete mode 100644 modules/openapi-generator/src/main/resources/scala-sttp/paramQueryCreation.mustache diff --git a/modules/openapi-generator/src/main/resources/scala-sttp/paramQueryCreation.mustache b/modules/openapi-generator/src/main/resources/scala-sttp/paramQueryCreation.mustache deleted file mode 100644 index 8a1ea8cfcbf7..000000000000 --- a/modules/openapi-generator/src/main/resources/scala-sttp/paramQueryCreation.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isContainer}}${ formatQueryArray("{{{baseName}}}",{{{paramName}}}{{#collectionFormat}}, {{collectionFormat.toUpperCase}}{{/collectionFormat}}) }{{/isContainer}}{{^isContainer}}{{baseName}}=${ {{{paramName}}} }{{/isContainer}} \ No newline at end of file