Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Swagger UI's cannot co-exist #161

Open
sauterl opened this issue Feb 20, 2023 · 6 comments · Fixed by #166
Open

Multiple Swagger UI's cannot co-exist #161

sauterl opened this issue Feb 20, 2023 · 6 comments · Fixed by #166
Labels
enhancement New feature or request scope: runtime

Comments

@sauterl
Copy link
Contributor

sauterl commented Feb 20, 2023

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 at javalin. 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.

sauterl added a commit to sauterl/javalin-openapi that referenced this issue Feb 20, 2023
@dzikoysk
Copy link
Member

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? 🤔

@sauterl
Copy link
Contributor Author

sauterl commented Feb 20, 2023

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.

@dzikoysk
Copy link
Member

Ok, because I was wondering if versioned scheme with switch option in Swagger UI is not enough, but it sounds reasonable as well.

@rvaidya
Copy link

rvaidya commented Apr 20, 2023

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.

@sauterl
Copy link
Contributor Author

sauterl commented Apr 20, 2023

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

dzikoysk added a commit that referenced this issue Apr 26, 2023
* Resolved #161 by checking first if a webjarhandler is registered

* Addressed PR comment and expanded unit test

* GH-166 Code review

---------

Co-authored-by: dzikoysk <[email protected]>
@dzikoysk dzikoysk reopened this Apr 26, 2023
@dzikoysk
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request scope: runtime
Projects
None yet
3 participants