[BUG][SCALA][AKKA] The base URL is hardcoded in API class
Created by: aneksamun
Hi,
I found a bug in scala-akka-client
module. In the api.mustache
file the basePath is been set to basePath instead of provided baseUrl. As result there is no way I can set correct URL. Please find example of autogenerated file:
object DefaultApi {
def apply(baseUrl: String = "http://localhost/some-api") = new DefaultApi(baseUrl)
}
class DefaultApi(baseUrl: String) {
def getSomeDetails(id: String): ApiRequest[SomeDetails] =
// Please note basePath is hardcoded - it is always localhost!
ApiRequest[SomeDetails](ApiMethods.GET, "http://localhost/some-api", "/v1/fetch/{id}", "application/json")
.withPathParam("id", id)
.withSuccessResponse[SomeDetails](200)
.withErrorResponse[ErrorResponse](400)
.withErrorResponse[ErrorResponse](404)
.withErrorResponse[ErrorResponse](500)
}
The bug is present in v4.1.2 (master).
The possible fix is in api.mustache file in line 24 replace line
ApiRequest[{{>operationReturnType}}](ApiMethods.{{httpMethod.toUpperCase}}, "{{{basePath}}}", "{{{path}}}", {{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}{{^consumes}}"application/json"{{/consumes}})
with
ApiRequest[{{>operationReturnType}}](ApiMethods.{{httpMethod.toUpperCase}}, baseUrl, "{{{path}}}", {{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}{{^consumes}}"application/json"{{/consumes}})
Thanks.