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 swagger-swaggersocket+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to