At the risk of sounding really ignorant, what do you mean I "already have a 
web service"?  Right now I have the SwaggerUI pointing to the swagger.json 
file from the index.html file as such:

      if (url && url.length > 1) {
>
>         url = decodeURIComponent(url[1]);
>
>       } else {
>
>         url = "/myContext/swagger.json";
>
>       }
>
> The UI then renders the swagger.json file from there.  Isn't that just 
pointing to a json file?  Are you saying that's actually a webservice?

Forgive my ignorance...

On Thursday, February 23, 2017 at 2:30:34 PM UTC-5, Ron wrote:
>
> You already have a web service, hosting your API and swagger.json. You 
> only need to write the Filter, configure swagger-core to use it, sit back, 
> and relax.
>
>  
>
>  
>
>  
>
> *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 11:23
> *To: *Swagger <[email protected] <javascript:>>
> *Subject: *Re: Dynamic Filtering of APIs
>
>  
>
> Ah.  So you're saying that I could create a web service (like I was 
> thinking in solution #3) that would invoke the ApiAuthorizationFilter using 
> some passed in parameters that would essentially just give me back a subset 
> of the overall swagger.json as desired?   
>
>  
>
> If that's the case then does the ApiAuthorizationFilter already inherently 
> have access to the swagger.json file?
>
> On Thursday, February 23, 2017 at 2:15:44 PM UTC-5, Ron wrote: 
>
> No. The filter executed before the swagger.json returns to the consumer 
> and allows for dynamic filtering of operations and parameters.
>
>  
>
>  
>
>  
>
> *From: *<[email protected]> on behalf of Bryan Nelson <
> [email protected]>
> *Reply-To: *"[email protected]" <
> [email protected]>
> *Date: *Thursday, 23 February 2017 at 11:14
> *To: *Swagger <[email protected]>
> *Subject: *Re: Dynamic Filtering of APIs
>
>  
>
> I'm not changing them dynamically at runtime.  Perhaps I am 
> misunderstanding when the ApiAuthorizationFilter would get applied?  It 
> seems like this would happen as a "one-time thing" on when the very first 
> swagger call was made.  Is that correct?
>
> On Thursday, February 23, 2017 at 2:10:02 PM UTC-5, Ron wrote: 
>
> Are you changing your resources dynamically at runtime? If not, I don’t 
> understand why you need to regenerate the swagger.json.
>
>  
>
>  
>
>  
>
> *From: *<[email protected]> on behalf of Bryan Nelson <
> [email protected]>
> *Reply-To: *"[email protected]" <
> [email protected]>
> *Date: *Thursday, 23 February 2017 at 11:06
> *To: *Swagger <[email protected]>
> *Subject: *Re: Dynamic Filtering of APIs
>
>  
>
> Hi Ron, 
>
>  
>
> Yes I have.  This is the kind of filter I would like to implement in my 
> solution #3.  But my understanding as of now is that the 
> ApiAuthorizationFilter would only help me if I didn't need to regenerate 
> the swagger.json on the fly.  Is there a way to regenerate the swagger.json 
> file *with the application still running whenever desired*?  If that 
> isn't possible then I'm not sure how the ApiAuthorizationFilter could help 
> me...
>
>
> Thank you for your time,
>
> bryan
>
> On Thursday, February 23, 2017 at 1:58:30 PM UTC-5, Ron wrote: 
>
> Hi Brian,
>
>  
>
> Have you seen our own filtering option in swagger-core?
>
> Take a look at this sample to get an idea - 
> https://github.com/swagger-api/swagger-samples/blob/master/java/java-jersey2/src/main/java/io/swagger/sample/util/ApiAuthorizationFilterImpl.java
> .
>
>  
>
>  
>
> *From: *<[email protected]> on behalf of Bryan Nelson <
> [email protected]>
> *Reply-To: *"[email protected]" <
> [email protected]>
> *Date: *Thursday, 23 February 2017 at 10:38
> *To: *Swagger <[email protected]>
> *Subject: *Dynamic Filtering of APIs
>
>  
>
> Greetings, 
>
>  
>
> I've inherited a JAX-RS rest-based Java application that contains roughly 
> 350 operations.  I have a need to dynamically generate multiple subset APIs 
> out of this codebase based upon certain criteria at runtime.  For example, 
> perhaps I want to generate an API that contains all of the "Brand X", 
> "Employee", and "User" services.  But I also want to see an API that has 
> all of "Brand Y" and "User" services.  I know that this can be done using 
> the tagging elements of the Java annotations, but the trouble is I would 
> have to alter the Java code and hide/unhide different operations, then 
> re-build, restart the server, etc. each time I wanted to see a different 
> subset of the API.  The limitation that I see with Swagger-Core out of the 
> box is that the entire swagger.json file is generated upon server startup / 
> first Swagger hit (please correct me if I'm wrong on that). 
>
>  
>
>  
>
> Now in order to meet my need I have a few ideas.  All of them involve 
> initially placing all the appropriate tags on each service operation in the 
> Java code to begin with.
>
>  
>
>    1. UI Solution - Generate the complete API from a full swagger.json 
>    file that includes all operations.  Based upon some UI user inputs 
> (perhaps 
>    checkboxes for "Brand X", "Brand Y", "User", etc.) parse through the full 
>    swagger.json file via Javascript and basically "filter out" all of the 
> tags 
>    that aren't checked by the user, thus creating a subset swagger.json of 
>    only the desired tagged operations which can then be displayed via Swagger 
>    UI.
>    2. Post-Json-Generated Java Solution - Generate the complete API from 
>    a full swagger.json file that includes all operations.  Create a 
> rest-based 
>    web service that takes in user inputs in the request (for "Brand X", 
> "Brand 
>    Y", "User", etc.), parse through the full swagger.json file using Java 
>    (Jackson, Gson, etc.), and basically "filter out" all of the tags that 
>    aren't checked by the user, thus creating a subset swagger.json of only 
> the 
>    desired tagged operations which can then be returned in the service 
>    response and used via whatever UI technology desired
>    3. Pre-Json-Generated Java Solution - Figure out a way to regenerate 
>    the swagger.json file *with the application still running whenever 
>    desired*, and then generate the partial API from a partial 
>    swagger.json file that includes only the desired operations based upon the 
>    tags (for "Brand X", "Brand Y", "User", etc.) using a Java Filter.  This 
>    could be run before the swagger.json file was created so only the desired 
>    subset was ever created based upon input parameters (e.g. the tag names). 
>     This could potentially be created as a rest-based service as well.
>
>  
>
> I'd love some input on these solutions.  I think that #2 is desirable over 
> #1 because it is not coupled to any UI implementation at all and would be 
> more reusable.  However, I think that, if possible, #3 would be the best 
> way to go.  My mine question is there even a way to accomplish #3?  Can you 
> the swagger.json file be regenerated without restarting the server?
>
>  
>
> Also, is there a better/known way to achieve what I'm trying to do?
>
>  
>
> Any thoughts are very much appreciated; thanks for your time!
>
>  
>
>  
>
> -- 
> 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.

Reply via email to