@Api("ignored") static class ApidocJaxrsSpecParser extends JaxrsApiSpecParser { public ApidocJaxrsSpecParser(Class<?> target, String apiVersion, String swaggerVersion, String basePath, String apiPath) { super(target, apiVersion, swaggerVersion, basePath, apiPath); } @Override public Api apiEndpoint() { // return an ignored item; all clients do is check it isn't null return ApidocJaxrsSpecParser.class.getAnnotation(Api.class); } public String getPath(Method method) { Path cwsPath = hostClass().getAnnotation(Path.class); Path mwsPath = method.getAnnotation(Path.class); if (cwsPath==null) return null; return cwsPath.value() + (mwsPath!=null ? mwsPath.value() : ""); } }
description = apidoc.description(); } else { path = apidocX.value(); description = apidocX.description();
@GET @Path("/{resource}") public Response details( @Context ResourceConfig rc, @Context HttpHeaders headers, @Context UriInfo uriInfo, @PathParam("resource") String resource) { Class<?> target = getResourceOfLink(rc, resource); if (target==null) return Response.status(Response.Status.NOT_FOUND).build(); // roughly duplicates JavaHelp String apiVersion = getConfigReader().getApiVersion(); String swaggerVersion = getConfigReader().getSwaggerVersion(); String basePath = getConfigReader().getBasePath(); String apiFilterClassName = getConfigReader().getApiFilterClassName(); Apidoc apidoc = target.getAnnotation(Apidoc.class); Api apidocX = target.getAnnotation(Api.class); Path rsPath = target.getAnnotation(Path.class); if ((apidoc==null && apidocX==null) || rsPath==null) return Response.status(Response.Status.NOT_FOUND).build(); String apiPath = apidoc!=null ? rsPath.value() : apidocX.value(); HelpApi helpApi = new HelpApi(apiFilterClassName); Documentation doc = read(target, apiVersion, swaggerVersion, basePath, apiPath); Documentation docs = helpApi.filterDocs(doc, headers, uriInfo, apiPath, apiPath); return Response.ok().entity(docs).build(); }
description = apidoc.description(); } else { path = apidocX.value(); description = apidocX.description();
@GET @Path("/{resource}") public Response details( @Context ResourceConfig rc, @Context HttpHeaders headers, @Context UriInfo uriInfo, @PathParam("resource") String resource) { Class<?> target = getResourceOfLink(rc, resource); if (target==null) return Response.status(Response.Status.NOT_FOUND).build(); // roughly duplicates JavaHelp String apiVersion = getConfigReader().getApiVersion(); String swaggerVersion = getConfigReader().getSwaggerVersion(); String basePath = getConfigReader().getBasePath(); String apiFilterClassName = getConfigReader().getApiFilterClassName(); Apidoc apidoc = getAnnotation(target, Apidoc.class); Api apidocX = getAnnotation(target, Api.class); Path rsPath = getAnnotation(target, Path.class); if ((apidoc==null && apidocX==null) || rsPath==null) return Response.status(Response.Status.NOT_FOUND).build(); String apiPath = apidoc!=null ? rsPath.value() : apidocX.value(); HelpApi helpApi = new HelpApi(apiFilterClassName); Documentation doc = read(target, apiVersion, swaggerVersion, basePath, apiPath); Documentation docs = helpApi.filterDocs(doc, headers, uriInfo, apiPath, apiPath); return Response.ok().entity(docs).build(); }
@Api("ignored") static class ApidocJaxrsSpecParser extends JaxrsApiSpecParser { public ApidocJaxrsSpecParser(Class<?> target, String apiVersion, String swaggerVersion, String basePath, String apiPath) { super(target, apiVersion, swaggerVersion, basePath, apiPath); } @Override public Api apiEndpoint() { // return an ignored item; all clients do is check it isn't null return ApidocJaxrsSpecParser.class.getAnnotation(Api.class); } @Override public Class<?> hostClass() { // Overriding to make sure we have a look at the interfaces (Jersey jaxrs implementation doesn't bother) // Note this means we require the @Path class annotation on the same class as all the method annotations for (Class<?> tryMe : ImmutableList.<Class<?>>builder().add(super.hostClass()).add(super.hostClass().getInterfaces()).build()) { if (tryMe.getAnnotation(Path.class) != null) { return tryMe; } } return super.hostClass(); } public String getPath(Method method) { Path cwsPath = hostClass().getAnnotation(Path.class); Path mwsPath = method.getAnnotation(Path.class); if (cwsPath==null) return null; return cwsPath.value() + (mwsPath!=null ? mwsPath.value() : ""); } }