Skip to content

Commit 7bb8a8d

Browse files
authored
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
1 parent fff5bfe commit 7bb8a8d

File tree

2 files changed

+6
-6
lines changed
  • modules/openapi-generator/src/main/resources/scala-akka-client
  • samples/client/petstore/scala-akka/src/main/scala/org/openapitools/client/core

2 files changed

+6
-6
lines changed

modules/openapi-generator/src/main/resources/scala-akka-client/apiInvoker.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC
103103
request: HttpRequest =>
104104
credentialsSeq.foldLeft(request) {
105105
case (req, BasicCredentials(login, password)) =>
106-
req.withHeaders(Authorization(BasicHttpCredentials(login, password)))
106+
req.addHeader(Authorization(BasicHttpCredentials(login, password)))
107107
case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) =>
108-
req.withHeaders(RawHeader(keyName, keyValue.value))
108+
req.addHeader(RawHeader(keyName, keyValue.value))
109109
case (req, BearerToken(token)) =>
110-
req.withHeaders(RawHeader("Authorization", s"Bearer $token"))
110+
req.addHeader(RawHeader("Authorization", s"Bearer $token"))
111111
case (req, _) => req
112112
}
113113
}

samples/client/petstore/scala-akka/src/main/scala/org/openapitools/client/core/ApiInvoker.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC
113113
request: HttpRequest =>
114114
credentialsSeq.foldLeft(request) {
115115
case (req, BasicCredentials(login, password)) =>
116-
req.withHeaders(Authorization(BasicHttpCredentials(login, password)))
116+
req.addHeader(Authorization(BasicHttpCredentials(login, password)))
117117
case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) =>
118-
req.withHeaders(RawHeader(keyName, keyValue.value))
118+
req.addHeader(RawHeader(keyName, keyValue.value))
119119
case (req, BearerToken(token)) =>
120-
req.withHeaders(RawHeader("Authorization", s"Bearer $token"))
120+
req.addHeader(RawHeader("Authorization", s"Bearer $token"))
121121
case (req, _) => req
122122
}
123123
}

0 commit comments

Comments
 (0)