I finally figured out the issue here. Apparently the problem with the
original design was that I was extending BaseApiListingResource on the same
class where I was trying to implement ReaderListener. For whatever reason
(feel free to comment if you know why) the ReaderListenerwasn't working
whenever I extend BaseApiListingResource. If I implement ReaderListener on
a class that doesn't extend BaseApiListingResource then *beforeScan* and
*afterScan* work just fine.
Hope this helps someone...
On Friday, April 28, 2017 at 1:40:42 PM UTC-4, Bryan Nelson wrote:
>
> Greetings,
>
> I am trying to invoke the afterScan(...) method from the ReaderListener
> interface but it is not being called. Here's my code:
>
> @Path("/myUrl/swagger/{type:json|yaml}")
> public class MyApiListingResource extends BaseApiListingResource
> implements ReaderListener {
>
>
> @Context
> ServletContext context;
>
>
> @GET
> @Produces({MediaType.APPLICATION_JSON, "application/yaml"})
> @ApiOperation(value = "The swagger definition in either JSON or YAML",
> hidden = true)
> public Response getListing(@Context Application app, @Context
> ServletConfig servletConfig, @Context HttpHeaders headers,
> @Context UriInfo uriInfo, @PathParam("type") String type)
> throws JsonProcessingException {
>
> if (isNotBlank(type) && type.trim().equalsIgnoreCase("yaml")) {
>
> return getListingYamlResponse(app, context, servletConfig,
> headers, uriInfo);
>
> } else {
>
> System.out.println("I found json!");
>
> return getListingJsonResponse(app, context, servletConfig,
> headers, uriInfo);
> }
> }
>
> @Override
> public void beforeScan(Reader reader, Swagger swagger) {
>
> System.out.println("I'm before!!!");
>
>
> }
>
> @Override
> public void afterScan(Reader reader, Swagger swagger) {
>
> System.out.println("I'm after!!!");
>
> }
>
> }
>
>
> Now when I call the following service:
>
> *http://localhost:9081/myApp/myUrl/swagger/json
> <http://localhost:9081/myApp/myUrl/swagger/json>*
>
>
> I do receive the "I found json!" in my console...but neither "I'm
> before!!!" or "I'm after!!!" are printed.
>
> Any ideas are welcome! Thanks!
>
--
You received this message because you are subscribed to the Google Groups
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.