springspringfox

How does the @ApiOperation annotation work in spring?


I want to know how does the annotation from spring @ApiOperation(value = "<Your Message>", hidden = true) work to hide information on my swagger page.

  1. What class is responsible to load the annotation
  2. What does it do with that same values of the annotation.

Where can I find how the annotation works?


Solution

  • The springfox.documentation.spring.web.readers.operation.ApiOperationReader.read(RequestMappingContext) method orchestrates the scanning of methods annotated with @ApiOperation and takes into consideration the hidden flag when doing so, you can see it in the sourcecode over at GitHub.

    The specific method that scans the annotated methods and populates the context with the information regarding whether such method should be hidden or not can be found here.

    You can keep browsing the source code for more information regarding the implementation, and you can also get more information regarding the @ApiOperation annotation over at https://github.com/swagger-api/swagger-core/wiki/annotations#apioperation.