Open stefankoppier opened 3 months ago
It's the same behavior as for resttemplate and webclient. The basePath
is listed as a feature for all java clients in the documentation.
As seen in the sample it's intended to be used like this:
new MyApi(new ApiClient().setBasePath("https://example.org/v1"))
It's not a bug, it's a feature 😅
I don't think that this is the best way to handle the URL but currently it's the way how the three spring clients work. 🤷♂️
If really needed one could add a new config value to switch between basePath and use whatever the client get set.
In my opinion, it's a really weird design choice, if it's not an overlooked feature of Spring. But with what you say, you can argue it not a bug.
I personally wouldn't clutter the config with extra options. It might be a possibility to change the default value from localhost to null, and use the client one if it's not set. i.e. only use basePath to override the client one if it's set.
But this, if this would be implemented, should be implemented in all clients, and shouldn't be breaking. I'm not sure about that. It is a inconsistency between the Kotlin variants and the Java variants, the Kotlin variants do use the paths of the clients.
Bug Report Checklist
Description
The baseUrl of the spring restclient is ignored, but instead, the basePath of the ApiClient is used. This is incorrect behaviour.
openapi-generator version
Since inception of library: 7.6.0.
OpenAPI declaration file content or url
Any declaration.
Generation Details
Java with the restclient library.
Steps to reproduce
Generate a client using Java with spring restclient as a library. Create an instance of an API, e.g.
MyApi(ApiClient(someRestClientBuilder.baseUrl(url).build()))
then call an API. This will fall-back to the default url configured in the ApiClientlocalhost
, but this should beurl
.A workaround is to write something like
MyApi(ApiClient(someRestClientBuilder.baseUrl(url).build()).setBasePath(url))
Related issues/PRs
None found
Suggest a fix
I will make a PR, if I have the time.