OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[x] Have you provided a full/minimal spec to reproduce the issue?
[x] Have you validated the input using an OpenAPI validator (example)?
[x] What's the version of OpenAPI Generator used?
[x] Have you search for related issues/PRs?
[x] What's the actual output vs expected output?
Description
The openapi-generator-gradle-plugin is generating the endpoints as absolute paths, with leading / like /pets, instead of relative like pets.
And because the path is absolute - Retrofit seems to be ignoring any path information given to the builder in the .baseUrl(HttpUrl) function. It seems to just be taking the schema and host, and ignoring any base path given to it.
Info from Retrofit's site:
Endpoint values which contain a leading `/` are absolute.
Absolute values retain only the host from baseUrl and ignore any specified path components.
Base URL: http://example.com/api/
Endpoint: /foo/bar/
Result: http://example.com/foo/bar/
Bug Report Checklist
Description
The
openapi-generator-gradle-plugin
is generating the endpoints as absolute paths, with leading/
like/pets
, instead of relative likepets
. And because the path is absolute - Retrofit seems to be ignoring any path information given to the builder in the .baseUrl(HttpUrl) function. It seems to just be taking the schema and host, and ignoring any base path given to it.Info from Retrofit's site:
openapi-generator version
org.openapi.generator version "4.3.1"
OpenAPI declaration file content or url
https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml
Steps to reproduce
This is the setup: gradle task:
generated PetsApi interface:
initialising the petsApi:
Suggest a fix
Maybe to have the generating an absolute paths configurable.
Similar / related
Here is the same issue described on stackoverflow - https://stackoverflow.com/questions/32352159/retrofit-2-removes-characters-after-hostname-from-base-url There is a presentation how to fix the issue manually, like removing the leading
/
to make the path relative. https://www.youtube.com/watch?v=KIAoQbAu3eA&feature=youtu.be&t=32m50s Screenshot from the video: