Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3957
Closed
Open
Issue created Sep 26, 2019 by Administrator@rootContributor

[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.

Assignee
Assign to
Time tracking