forked from loafle/openapi-generator-original
* 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:
+3
-3
@@ -103,11 +103,11 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC
|
||||
request: HttpRequest =>
|
||||
credentialsSeq.foldLeft(request) {
|
||||
case (req, BasicCredentials(login, password)) =>
|
||||
req.withHeaders(Authorization(BasicHttpCredentials(login, password)))
|
||||
req.addHeader(Authorization(BasicHttpCredentials(login, password)))
|
||||
case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) =>
|
||||
req.withHeaders(RawHeader(keyName, keyValue.value))
|
||||
req.addHeader(RawHeader(keyName, keyValue.value))
|
||||
case (req, BearerToken(token)) =>
|
||||
req.withHeaders(RawHeader("Authorization", s"Bearer $token"))
|
||||
req.addHeader(RawHeader("Authorization", s"Bearer $token"))
|
||||
case (req, _) => req
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -113,11 +113,11 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC
|
||||
request: HttpRequest =>
|
||||
credentialsSeq.foldLeft(request) {
|
||||
case (req, BasicCredentials(login, password)) =>
|
||||
req.withHeaders(Authorization(BasicHttpCredentials(login, password)))
|
||||
req.addHeader(Authorization(BasicHttpCredentials(login, password)))
|
||||
case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) =>
|
||||
req.withHeaders(RawHeader(keyName, keyValue.value))
|
||||
req.addHeader(RawHeader(keyName, keyValue.value))
|
||||
case (req, BearerToken(token)) =>
|
||||
req.withHeaders(RawHeader("Authorization", s"Bearer $token"))
|
||||
req.addHeader(RawHeader("Authorization", s"Bearer $token"))
|
||||
case (req, _) => req
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user