Forum Discussion

DeeGee's avatar
DeeGee
Occasional Visitor
2 years ago

Combining @Path Annotations

Hi,

 

I'm having an issue with Swagger Annotations not picking up the combined Path annotations between a class with a defined Path annotation that calls and returns another class, which also continues the endpoint path through its own class Path annotation.  This latter class has multiple endpoints with their own Path annotations as well.  For example (Java):

 

@Path("first")

public class FirstClass {

   @Path("{first}/second")

   public SecondClass getSecond(@PathParam("first") FirstId firstId) {

      return new SecondClassImpl(firstId);

   }

 

@Path("second")

public interface SecondClass {

   @GET

   @Path("{second}/related/maps")

   @Produces(MediaType.APPLICATION_JSON)

   List<SecondClass> getRelatedMaps(@PathParam("first") FirstId firstId, @PathParam("second") SecondId secondId);

}

 

The generated definition file of course shows the path of this service as /second/{second}/related/maps, however the server sees it as /first/{first}/second/{second}/related/maps.  In other words, when calling the service from a browser directly, the full path works fine.  However, when calling the service from the swagger UI page, it can't find it due to the incorrect shortened path.  So my question is, is there a way to append "/first/{first} to the second part of the path using the @Operation annotation, for example?  We're using OpenApi 3.0.

 

Thank you. 

No RepliesBe the first to reply