Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG][SCALA][AKKA] The base URL is hardcoded in API class #3957

Closed
aneksamun opened this issue Sep 26, 2019 · 1 comment
Closed

[BUG][SCALA][AKKA] The base URL is hardcoded in API class #3957

aneksamun opened this issue Sep 26, 2019 · 1 comment

Comments

@aneksamun
Copy link
Contributor

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.

@aneksamun aneksamun changed the title [BUG][SCALA-AKKA] The base URL is hardcoded in API class [BUG][SCALA][AKKA] The base URL is hardcoded in API class Sep 26, 2019
@aneksamun
Copy link
Contributor Author

PR: #3964

jimschubert added a commit that referenced this issue Sep 30, 2019
* master: (207 commits)
  Add missing enum processing in C++ codegen, already present for Qt5 (#3986)
  [C++] [Pistache] Removed deprecated warnings (#3985)
  [C++][Pistache] Simplified model template (#3417)
  add go oas3 petstore to ensure up-to-date (#3979)
  replace gitter with slack in the doc (#3977)
  Fix wrong variable name in LessThan and LessThanOrEqual asserts (#3971)
  #3957 - Removed hardcoded baseUrl (#3964)
  Regenerate go openapi3 samples (#3975)
  [rust] Make it easier to test rust client generator (#3543)
  Fix issue3635 (#3948)
  add gradle repository (#3867)
  [java] allow to use setArtifactVersion() programmatically (#3907)
  Add a link to DevRelCon SF 2019 (#3961)
  Add a link to a medium blog post (#3960)
  update maven-compiler-plugin version (#3956)
  fix generateAliasAsModels in default generator (#3951)
  Implement BigDecimal to Decimal in swift4 for currency data as type=string format=number (#3910)
  Add F# Functions server generator (#3933)
  [python-experimental] generate model if type != object if enums/validations exist (#2757)
  [scala] add [date-time] field to codegen unit test (#3939)
  ...
Jesse0Michael pushed a commit to Jesse0Michael/openapi-generator that referenced this issue Oct 3, 2019
jimschubert added a commit that referenced this issue Oct 4, 2019
* master: (110 commits)
  [golang] Regenerate all go samples  (#3988)
  Better tests for string (number) (#3953)
  Add missing enum processing in C++ codegen, already present for Qt5 (#3986)
  [C++] [Pistache] Removed deprecated warnings (#3985)
  [C++][Pistache] Simplified model template (#3417)
  add go oas3 petstore to ensure up-to-date (#3979)
  replace gitter with slack in the doc (#3977)
  Fix wrong variable name in LessThan and LessThanOrEqual asserts (#3971)
  #3957 - Removed hardcoded baseUrl (#3964)
  Regenerate go openapi3 samples (#3975)
  [rust] Make it easier to test rust client generator (#3543)
  Fix issue3635 (#3948)
  add gradle repository (#3867)
  [java] allow to use setArtifactVersion() programmatically (#3907)
  Add a link to DevRelCon SF 2019 (#3961)
  Add a link to a medium blog post (#3960)
  update maven-compiler-plugin version (#3956)
  fix generateAliasAsModels in default generator (#3951)
  Implement BigDecimal to Decimal in swift4 for currency data as type=string format=number (#3910)
  Add F# Functions server generator (#3933)
  ...
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant