How to add two different paths to the same endpoint in swagger?
Asked Answered
T

0

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?

Takara answered 1/2, 2017 at 19:8 Comment(6)
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?Equities
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.Takara
Hey can you clarify about how are you trying to add swagger annotations?Discreet
@Discreet 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.Takara
Did you ever find an answer to this?Supposition
@Simon nope. I gave up and built this manually.Takara

© 2022 - 2024 — McMap. All rights reserved.