-
Notifications
You must be signed in to change notification settings - Fork 6k
-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
basePath specified in swagger file is ignored by spring code generator #5244
basePath specified in swagger file is ignored by spring code generator #5244
Comments
Is this the same as #3720? |
Yes it is the same problem. |
@Frank-Stephan so did the following resolve the issue for you? |
In 3720 was suggested to change the base path in the spring configuration file (server.contextPath=/v2). This is not feasible for me, as it moves all rest endpoints including spring boot health endpoints. In addition I see then no way to provide two API versions out of one micro service. |
@Frank-Stephan so your requirement is to change |
No, my expectation was that the code generator for spring takes the basePath specified in the swagger file into account. The contextPath of spring has another purpose. It moves all rest endpoints including those provided by spring itself. We want to use the basePath to put a version number into it that is prepended to all rest endpoints specified in the swagger file. Of course if there were a spring feature with which we can prepend all endpoints of our swagger api with a version number we would have used it as a workaround. |
I have the same issue. Do you know when the fix is planned? |
@Frank-Stephan I think what the generator is doing with paths:
'/v1/persons/{id}':
### stuff |
I found a workaround that it works for me: I copied the application properties from the generated code to the src/main.resources. |
@fehguy I have a similar problem, but following the approach you suggest consolidates all my endpoints into a single api file, which apparently can then only to mapped to a single controller. Any suggestions on how one could get the base bath as Frank wanted and yet keep different controller implementations? I tried multiple controllers implementing different methods of the same single api interface, but that resulted in an ambiguous mapping exception. |
Frankly, I'm not sure why the issue was closed.
Lacking the ability to handle the
But sorry, there is no resource like |
And a workaround by @erreobi may not work for everyone. For example, I never check in a generated code to a source repository and never copy parts of it to my sources. It is an endless source of inconsistencies. Just imagine, you changed your Swagger model and the generated code is changed. Who should then know all places, where a part of the generated code has been replicated to? This might work for a one-person project, but in a team environment might be challenging... |
This issue still persists. Please let us know when a fix is expected. |
Adding ...
@RequestMapping(value = "{{{contextPath}}}")
... as annotation to |
@kerkhofsd this will produce request mapping with only a base path. What worked for me, is |
@ok11 @RequestMapping(value = "{{{contextPath}}}")
public interface {{classname}} { |
Right. Sorry, haven't realized what you mean. Yes, your suggestion is definitely better. Would you then initiate a PR with the proposal? |
@kerkhofsd Any chance of a PR for your fork and fix, would be great to see it fixed upstream. |
#8131 |
Awesome! Thank you. |
I don't understand if this problem was fixed and merged to the master branch since even though i have basePath i my swagger file I don't see it in the generated interface file |
Any word on this? BasePath is still not being added to my requestMapping in Spring. Here's the relevant part of my spec file.
Here's the request mapping from the java controller. There is no
This should be |
#8131 |
Ping... |
Any progress on this? Currently we manually have to copy the base path and attach it to hostname in configuration. That should not be the case. Currently the basepath in swagger basically useless... This is an issue both server( and I can understand that it may be difficult to implement ) but whyfor client as well? |
Again this is something that we've run into when developing using Swagger's generated Spring code. |
when will this fix be merged? |
Hello, would be interested in an update as well! Thanks |
hey guys, i'll take a look on this next week. |
[Spring] Fixes #5244 Include basePath @RequestMapping in Spring API template
Description
A basePath specified in a swagger file is ignored by the spring code generator. Annotation @RequestMapping doesn't contain it.
Swagger-codegen version
2.2.2 (swagger-codegen-maven-plugin)
Swagger declaration file content or url
generates:
Command line used for generation
Steps to reproduce
Related issues
Suggest a Fix
The text was updated successfully, but these errors were encountered: