-
Notifications
You must be signed in to change notification settings - Fork 52
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
Serve swagger ui from embedded resources #69
base: master
Are you sure you want to change the base?
Conversation
@DenisPalnitsky This sounds like a great feature, however, I feel like it should be conditional and off by default, especially because this will have an impact on the final binary size. |
@wI2L That's a reasonable concern. We can also move the |
Yes, that's better indeed. |
Is that what you mean?
Judging by my use-case, I would not want to be forced to create a group to host UI. Also, if it's part of the group then it will be visible in open-api spec, which is not desirable. |
There is a small catch. Every time we update those assets we need to change |
fae5a5b
to
72368d2
Compare
Codecov Report
@@ Coverage Diff @@
## master #69 +/- ##
==========================================
- Coverage 94.91% 94.28% -0.64%
==========================================
Files 7 9 +2
Lines 964 997 +33
==========================================
+ Hits 915 940 +25
- Misses 33 38 +5
- Partials 16 19 +3
Continue to review full report at Codecov.
|
@wI2L did you have a chance to check my comments? |
Sorry it took that long.
You're right. However, I stil dislike that the user has to pass the |
I don't know when or who will update the UI in the future, but since we simply need to download the latest Swagger UI bundle, unpack?, rename a file and replace a field value with a known template variable, I think it's sound easy enough, and might be worth to script it right away and forget about it. |
We had fizz method in the initial version but if the method is in the same package then assets are always part of the resulting binary even if UI is not used |
UI does not change that much so I don't expect that updates will be often. We can stay with the current UI forever. Also, Swagger team can change the format and the script won't work anymore. |
@wI2L would you consider merging it? |
We can use
And it can works; |
I would like to suggest serving Swagger UI from Fizz.
In this PR I'm embedding Swagger UI static files and adjusting
index.html
to use the Open API specification file name provided by the user.The only limitation is that it relies on go:embed that is available from 1.16
It will look as follows:
If you consider merging it I'll add a couple of tests.