swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Inheritance not working

Open b0c1 opened this issue 9 years ago • 3 comments

I try to do interface inheritance but the inherited method skipped from the API list...

My interface:

public interface ServiceController<Filter extends Serializable, Result> {

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_OCTET_STREAM)
    @Path("/print")
    @ApiOperation("Print customer grid based by filter and grid configuration")
    Response printing(PrintConfigDTO<Filter> printConfig);

    @POST
    @ApiOperation(value = "Return the customer data defined by filter")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    Result filter(FilterDTO<Filter> filter);
}

My implementation:

@Api(value = "/card/list", description = "Card List")
@Path("/card/list")
@Component
public class CardListController extends AbstractController implements ServiceController<CardListFilterDTO, CachePage<CardListItemDTO>> {
//...
    @Override
    public CachePage<CardListItemDTO> filter(FilterDTO<CardListFilterDTO> filter) {
        return cardService.getCardList(new ServiceRequest<>(getCallContext(), filter));
    }
//...

b0c1 avatar Feb 06 '17 10:02 b0c1

I try to investigate the problem. I think it's in swagger-jaxrs Reader class.

            for (Method method : methods) {
                AnnotatedMethod annotatedMethod = bd.findMethod(method.getName(), method.getParameterTypes());
                if (ReflectionUtils.isOverriddenMethod(method, cls)) {
                    continue;
                }

So I Can't implement a method? ??? more exactly the implemented method can't be exposed to outside? The JAX-RS specification allow to use inheritance (and it's works, just not exposed to jersey):

JAX-RS annotations may be used on the methods and method parameters of a super-class or an implemented interface. Such annotations are inherited by a corresponding sub-class or implementation class method provided that the method and its parameters do not have any JAX-RS annotations of their own. Annotations on a super-class take precedence over those on an implemented interface. The precedence over conflicting annotations defined in multiple implemented interfaces is implementation specific. Note that inheritance of class or interface annotations is not supported.

http://download.oracle.com/otn-pub/jcp/jaxrs-2_0_rev_A-mrel-eval-spec/jsr339-jaxrs-2.0-final-spec.pdf

b0c1 avatar Feb 06 '17 10:02 b0c1

I'm facing the same issue here. Based on the highlighted code snippet, the solution for that seems very easy. :-/

emobtech avatar Jul 25 '17 17:07 emobtech

Closing this issue as part of our backlog cleanup effort.
This issue is outdated and/or inactive for a long time, and we’re not able to revisit it meaningfully.

If this problem is still relevant, please open a new issue and reference this one for context.
Thank you for your understanding!

MichakrawSB avatar Mar 08 '26 19:03 MichakrawSB