Oh, right. Because I could essentially do something like this right now "/myContext/swagger.json?filter=whatever" and the service in ApiListingResource will be able to access that filter query param already.
I just have to reference the "filter" param in my filter...wow. It took a while, but I think I got there. Thanks again! On Thursday, February 23, 2017 at 4:34:31 PM UTC-5, Ron wrote: > > You actually shouldn’t need to modify ApiListingResource at all, just > create the filter. > > > > > > > > *From: *<[email protected] <javascript:>> on behalf of Bryan > Nelson <[email protected] <javascript:>> > *Reply-To: *"[email protected] <javascript:>" < > [email protected] <javascript:>> > *Date: *Thursday, 23 February 2017 at 13:24 > *To: *Swagger <[email protected] <javascript:>> > *Subject: *Re: Dynamic Filtering of APIs > > > > ApiListingResource.class is just a JAX-RS endpoint like any of your own. > > > > Oh.My.Goodness. I'll risk the egg on my face here and say that I never > realized that! I went on GitHub and looked at ApiListingResource.java and, > although I feel pretty dumb, everything is clear now! My main confusion > was that the web service path for ApiListingResource takes a file type as a > path param...I never realized that was actually a web service. I always > thought it was just accessing a file under the hood. > > > > Okay, so now I see what you mean. I can just extend AbstractSpecFilter > putting in my own filtering based upon passed in tags (via header, params, > whatever) and then also extend either ApiListingResource.java or, more > likely BaseApiListingResource.java, and alter the service there to accept > the input (via header, params, whatever) for the filtering items. > > > > Done. > > > > Thanks a lot for your patience Ron...this was *extremely* helpful! > > > > > > > > On Thursday, February 23, 2017 at 4:03:19 PM UTC-5, Ron wrote: > > Your getClasses() method in the Application class tells JAX-RS what to > scan (there are other methods as well). > > > > ApiListingResource.class is just a JAX-RS endpoint like any of your own. > > > > > > > > *From: *<[email protected]> on behalf of Bryan Nelson < > [email protected]> > *Reply-To: *"[email protected]" < > [email protected]> > *Date: *Thursday, 23 February 2017 at 12:54 > *To: *Swagger <[email protected]> > *Subject: *Re: Dynamic Filtering of APIs > > > > Now this is becoming more clear. > > > > The Application class is the starting point of your JAX-RS app. I > > > > Ok, I understand that. > > > > It triggers the scanning of your resources > > > > Ok. I got that. > > > > and exposes them as a rest service. > > > > This is where I'm confused...under what endpoint is it registered? Are > you saying it is just exposing it at the root of whatever the > ApplicationPath annotation has on the extended Application class? That > seems to be the case but I guess my confusion is where is that happening? > Does BeanConfig do that? > > > > Thanks for bearing with me; I really want to understand this! > > > > On Thursday, February 23, 2017 at 3:28:15 PM UTC-5, Ron wrote: > > The Application class is the starting point of your JAX-RS app. It > triggers the scanning of your resources and exposes them as a rest service. > > All you need to do is create your own Filter (extending AbstratSpecFilter) > and adding it to your beanConfig as you can see in > https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5#using-swaggers-beanconfig > . > > > > Look again at > https://github.com/swagger-api/swagger-samples/blob/master/java/java-jersey2/src/main/java/io/swagger/sample/util/ApiAuthorizationFilterImpl.java > . > > The `if(params.containsKey("api_key"))` code checks if there’s a parameter > called api_key. It’s just something we chose. You can choose to call it > tags or whatever you want. > > If you want to use a header instead, you can do that too. > > > > > > > > *From: *<[email protected]> on behalf of Bryan Nelson < > [email protected]> > *Reply-To: *"[email protected]" < > [email protected]> > *Date: *Thursday, 23 February 2017 at 12:20 > *To: *Swagger <[email protected]> > *Subject: *Re: Dynamic Filtering of APIs > > > > I'm not trying to be obtuse, but how is that a web service? Also, I need > it to accept input params (which would be the tags I'd want to dynamically > filter on) and I don't see anyway to make that happen in what I pasted > above? > > On Thursday, February 23, 2017 at 3:15:47 PM UTC-5, Ron wrote: > > So that’s your web service. You just need to add your filter to that. > > > > > > > > *From: *<[email protected]> on behalf of Bryan Nelson < > [email protected]> > *Reply-To: *"[email protected]" < > [email protected]> > *Date: *Thursday, 23 February 2017 at 12:06 > *To: *Swagger <[email protected]> > *Subject: *Re: Dynamic Filtering of APIs > > > > Ok, here's my setup. I have the UI working like mentioned above. I then > have a java class that extends javax.ws.rs.core.Application where I do > this: > > > > public class MyApplication extends Application { > > public MyApplication() { > > BeanConfig beanConfig = new BeanConfig(); > > beanConfig.setVersion("1.0"); > > beanConfig.setTitle("My App"); > > beanConfig.setDescription("My description."); > > beanConfig.setSchemes(new String[]{"http, https"}); > > beanConfig.setBasePath("/myContext/"); > > beanConfig.setResourcePackage("com.myPackage.rest.resource"); > > beanConfig.setPrettyPrint(true); > > beanConfig.setScan(true); > > } > > @Override > > public Set<Class<?>> getClasses() { > > > > > > Set<Class<?>> resources = new HashSet<Class<?>>(); > > resources.add(ApiListingResource.class); > resources.add(SwaggerSerializers.class); > > > > return resources; > > } > > > } > > > > That's all I have really besides all my annotations obviously. > > > > -- > 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. > > -- > 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] <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > -- > 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. > > -- > 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] <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > -- 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.
