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

Sttp - wrap query params #6884

Merged
merged 2 commits into from
Aug 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 }")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks promising! Does it make sense to wrap only those which have backticks or it is not easy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It it for sure an additional complication which doesn't bring any value IMO.

.contentType("application/json")
.response(asJson[Seq[Pet]])

Expand All @@ -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]])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down