7

Using javaws we can have multiple endpoints leading to the same method. Example:

@Path("/menus")
public class MenuResource {
    @Path("/{menuId}/sections")
    @Timed @ExceptionMetered
    public MenuSectionResource getSections(@InjectParam MenuSectionResource resource) {
        return resource;
    }
}

@Path("/sections")
public class MenuSectionResource {
    @GET
    public Section get(@PathParam("menuId") String menuId, @QueryParam("id") String id) {
        /// method accessed by GET in /sections or GET in /menus/{menuid}/sections
    }
}

I'm trying to use swagger to document both endpoints, but i can only use one @Api annotation in each class, so i can generate either /sections or /menus/{menuid}/sections. Is it possible to automatically generate both entries in the swagger.json output?

EricSchaefer
  • 25,272
  • 21
  • 67
  • 103
caiocpricci2
  • 7,714
  • 10
  • 56
  • 88
  • Is your code valid? Shouldn't this `@Path("/{menuId}/sections")` be on method in `MenuSectionResource` class? Where is a real problem? Can you clarify your problem? – ByeBye Mar 10 '17 at 08:10
  • Yeah the code is valid. That method is an entry point to another resource. Problem is using swagger annotations i can't document menus/ID/sections i can only document /sections, as it's only one method. – caiocpricci2 Mar 10 '17 at 14:22
  • Hey can you clarify about how are you trying to add swagger annotations? – Samarth Mar 15 '17 at 17:07
  • @Samarth well that's the problem. Following the docs i can add annotations that ties a method to an endpoint but i don't even know where to start to document both endpoints. – caiocpricci2 Mar 17 '17 at 03:18
  • Did you ever find an answer to this? – NotSimon Feb 12 '18 at 18:07
  • @Simon nope. I gave up and built this manually. – caiocpricci2 Feb 12 '18 at 21:43

0 Answers0