Open gh-nalo opened 8 months ago
Thanks for opening the issue, @gh-nalo.
So if I understood correctly, you need the generated code to look like this:
@Path("/someMethod")
@RegisterRestClient( configKey="someFile_json")
@GeneratedClass(value="someFile.json", tag = "Default")
@ApplicationScoped
public interface DefaultApi {
@POST
@Path("/")
@GeneratedMethod ("someMethod")
public javax.ws.rs.core.Response someMethod(
);
@POST
@Path("/{id}")
@GeneratedMethod ("someMethodId")
public javax.ws.rs.core.Response someMethodId(
);
}
Not sure what the implications are for others. I'm curious about your setup. Why is this not working without the trailing slash at the end? What kind of redirects do you have on your server?
@ricardozanini Our setup contains api gateway proxy responsible for intercepting, authenticating and routing of requests to corresponding api provider. If providers expose the api with trailing slash, consumer must provide it too otherwise request cant be matched and api gateway returns 404.
@ricardozanini Yes, that's what I'd expected the generated code to be
@michalsomora @gh-nalo feel free to open a PR.
@ricardozanini Hello, I submit a pull request yesterday. When you are available evaluate my code, please. Thank you!
Shouldn't it be possible to detect that the original URL has a slash ad the end, and THEN add the @Path("/")? That way, it should only be added when this edge case occurs. Cases where the original URL don't have the slash at the end with then not get one for free unexpectedly.
@ractoc feel free to take a look at the current PR #585. Not sure if @jeffersoncleyson will continue working on it.
Are there some news to this issue? I have a similar problem. The external api server responds with 404 if the trailing slash is missing. Bad practice, I think. Is there some solution in next time or a workaround? Thanks.
@wernert75 there's no workaround at the moment. Feel free to send a PR based on #585.
Using the openapi-generator has caused some minor issues in our application with redirecting calls, because the trailing "/"-slash is missing at the end of requests when there is more than one path defined in the OpenApi spec.
Example 1 - For the following Json:
this file is generated:
here the
@POST
has the trailing slash due to "/someMethod/" on class level.Example 2 - But in this case:
which creates
The first POST is now missing the "/" at the end after adding another endpoint with - for example - a query parameter. Would it be possible to add a default
@Path("/")
annotation here for the base-methods?