Open sauterl opened 1 year ago
a) This is something I'd like to add to Javalin 6.x as I've already seen such issues with OpenApiPlugin in the past
Btw, I'm just curious, why would you need to serve 2 Swagger UIs? 🤔
In our application we want to separate the internal and client-side openapi specs since third-party clients do not have to know about most of the internal calls. Yet, having openapi specs internally saves a lot of dev-time 😉 Side note: I purposely linked the openapi specs generated with this plugin.
Ok, because I was wondering if versioned scheme with switch option in Swagger UI is not enough, but it sounds reasonable as well.
If you were to serve 2 Swagger UIs, how would you note which one a route is supposed to be documented in when adding the @OpenApi
annotations?
This is also something that I'm looking to do - expose a public OpenApi endpoint with UIs for external clients and a separate internal set that requires auth to get to.
We did so by excluding the routes in the swagger-ui they shouldn't appear. Since one of the two openapi definitions is a subset of the other one, it was fairly trivial to do the exclusion.
Since I'm on mobile, I cannot easily point you towards the relevant code, but your starting point could be our repo
I'll keep this open, because we don't have built-in tools to support 2 standalone Swagger UIs. I'll keep this for Javalin 6.x as it'd require some breaking changes in current configs.
There is currently two issues with multiple swagger UIs:
a) one has to create a sub-class of the plugin as otherwise
javalin
wouldn't register it (I will read upon that and mention it over atjavalin
. I guess there are plugins for which only a single instance should exist). b) this fails as both instances try to add the webjar GET handler.The former can be counted as a minor inconvenience, the latter, however, is an easy fix which I will provide in due time.