Skip to content

Api and ApiImplicitParam annotations not read when using resource implementation #1746

@ghost

Description

Api and ApiImplicitParam annotations are not being parsed/read when they are used in a JAX-RS interface, as in the following example:

@Path("/pet")
@Api(tags = "someTag")
public interface ResourceWithAnnotationsOnlyInInterface {

    @GET
    @Path("/randomPet")
    @ApiOperation(value = "getRandomPet")
    @ApiImplicitParams({ @ApiImplicitParam(name = "petImplicitIdParam", paramType = "query", dataType = "string") })
    String getRandomPet();
}

public class ResourceWithAnnotationsOnlyInInterfaceImpl implements ResourceWithAnnotationsOnlyInInterface {

    @Override
    public String getRandomPet() {
        return "No pet today..";
    }
}

This issue is quite similar to issue #1506
The solution is also similar: use
Api api = ReflectionUtils.getAnnotation(cls, Api.class);

instead of
Api api = (Api) cls.getAnnotation(Api.class);

Noticed in swagger-core version 1.5.8

I will fix this and create a pull request for this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions