swagger-api / swagger-play

Apache License 2.0
330 stars 181 forks source link

Unsure if it's possible to use swagger play with dynamically selected routes #168

Open chrischandler25 opened 6 years ago

chrischandler25 commented 6 years ago

I have a multi module play app, where either ModuleA or ModuleB is active in a single instance. Which module is active is selected from configuration, and the routes file selected in a custom HttpRequestHandler, in almost the same way as the "Extending the default request handler" example at https://www.playframework.com/documentation/2.6.x/ScalaHttpRequestHandlers except using config rather than host to make the routes selection.

Each module has it's own routes config, and uses orElse to fall back to the root module routes if there is no match (for common functionality). The works perfectly in execution, but swagger only picks up routes from the root config. I tried creating a swagger.json entry in the module routes, as event "mysite.com/modulea/swagger.json" would have been OK, but this still produced the json for the root routes file and not the module.

It does work if I include "-> / moduleA.Routes" in the root routes file, but I want this to be selected by config so it's not a suitable solution.

Is there a way I can pass my routes to swagger-play to generate the json, rather than it use my routes file? I could add a case entry into my request match in the http hander when swagger.json is requested, and pass the complete routes object.

Many thanks for any suggestions.