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

@ApiParam values are not inhereted

Open mrj365 opened this issue 10 years ago • 9 comments

When I annotate the parameters with @ApiParam in the super class, I do not see its values in the UI. If I annotate the parameters on the implementation with @ApiParam I do see the values.

swagger-jersey2-jaxrs 1.5.7

Interface:

public interface ICategoryController {

    @ApiOperation(value = "Get all categories", notes = "Returns a list of categories", response = CategoryResponse.class, responseContainer="List")
    public Response getAllCategories(
                @ApiParam(value = "Start index of category id", allowableValues = "range[1,1000]", required = true) 
                @QueryParam(value="startIndex") int startIndex, 
                @ApiParam(value = "Limit the number of categories returned", allowableValues = "range[1,1000]", required = true)
                @QueryParam(value="size") int size);

}

Impl:

    @GET
    @Produces("application/json")
    public Response getAllCategories(@QueryParam(value="startIndex") int startIndex, @QueryParam(value="size") int size)
    {   
        List<Category> categoryList = sampleCategoryService.getAllCategories(startIndex, size);     
        return Response.ok(categoryList).build();       
    }

image

mrj365 avatar Feb 22 '16 18:02 mrj365

Any reason you have the JAX-RS annotations on both the interface and the implementation?

webron avatar Feb 22 '16 18:02 webron

I thought it would help make things more clear. I just tested witout the JAX-RS annotations in the interface and got the same result.

mrj365 avatar Feb 22 '16 18:02 mrj365

How about when you put them both in the same place (only)?

webron avatar Feb 22 '16 18:02 webron

If I put @ApiParam and @QueryParam only on the implementation, it works, but I am trying to avoid putting the swagger documentation on the implementation. If I put them both only on the interface I get a wierd result.

Both on Impl:

image

mrj365 avatar Feb 22 '16 18:02 mrj365

I don't think they inherit from the interface to the implementation

fehguy avatar Feb 22 '16 18:02 fehguy

Yes, that is why I opened they ticket. I was under the impression that they would. It seems like a bug. Should they be inherited?

mrj365 avatar Feb 22 '16 19:02 mrj365

Just to add a little more info, a similar issue was filed with springfox: https://github.com/springfox/springfox/issues/388

mrj365 avatar Feb 22 '16 19:02 mrj365

got it. If someone can point us in the direction of inheriting annotations in implementations, it should be easy to fix in the next release.

fehguy avatar Feb 22 '16 19:02 fehguy

similar to #1506, fixed in #1747

frantuma avatar Apr 22 '16 14:04 frantuma