Update apiInvoker.mustache and sample file for akka-scala client for issue #7258 fix (#7259)

* Update apiInvoker.mustache

In scala-akka-client code that is getting generated, addAuthentication method is called after setting headers using header parameter in the below mentioned line
addAuthentication(request.credentials)(
      httpRequest.withHeaders(headers(request.headerParams))
    )

However, in addAuthentication method, we are using withHeaders method that overwrites the headers set using header parameters. So, I am proposing to
change the addAuthentication method be replacing withHeaders() method to addHeader() to add authentication header to the list of already existing headers.

* Update ApiInvoker.scala

Added changes to sample for the client generator code change
This commit is contained in:
ParakhMittal 2020-08-23 19:12:16 +05:30 committed by GitHub
parent fff5bfe8cb
commit 7bb8a8d9ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -103,11 +103,11 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC
request: HttpRequest => request: HttpRequest =>
credentialsSeq.foldLeft(request) { credentialsSeq.foldLeft(request) {
case (req, BasicCredentials(login, password)) => case (req, BasicCredentials(login, password)) =>
req.withHeaders(Authorization(BasicHttpCredentials(login, password))) req.addHeader(Authorization(BasicHttpCredentials(login, password)))
case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) => case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) =>
req.withHeaders(RawHeader(keyName, keyValue.value)) req.addHeader(RawHeader(keyName, keyValue.value))
case (req, BearerToken(token)) => case (req, BearerToken(token)) =>
req.withHeaders(RawHeader("Authorization", s"Bearer $token")) req.addHeader(RawHeader("Authorization", s"Bearer $token"))
case (req, _) => req case (req, _) => req
} }
} }

View File

@ -113,11 +113,11 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC
request: HttpRequest => request: HttpRequest =>
credentialsSeq.foldLeft(request) { credentialsSeq.foldLeft(request) {
case (req, BasicCredentials(login, password)) => case (req, BasicCredentials(login, password)) =>
req.withHeaders(Authorization(BasicHttpCredentials(login, password))) req.addHeader(Authorization(BasicHttpCredentials(login, password)))
case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) => case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) =>
req.withHeaders(RawHeader(keyName, keyValue.value)) req.addHeader(RawHeader(keyName, keyValue.value))
case (req, BearerToken(token)) => case (req, BearerToken(token)) =>
req.withHeaders(RawHeader("Authorization", s"Bearer $token")) req.addHeader(RawHeader("Authorization", s"Bearer $token"))
case (req, _) => req case (req, _) => req
} }
} }