-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Added swagger plugin #162
Added swagger plugin #162
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @DanZ-ix
It looks good. I made some remarks that should be changed. I also tried this
[[swagger https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/api-with-examples.json]]
And it did not show the block.
src/wikmd/plugins/swagger/swagger.py
Outdated
|
||
injected_html = """ | ||
<div id="{id}"></div> | ||
<script src="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui-bundle.js" crossorigin></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to add it to web_dep
and do it like this
By doing this we allow the local_mode
to download all the remote files
src/wikmd/plugins/swagger/swagger.py
Outdated
|
||
class Plugin: | ||
def import_head(self): | ||
return '<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui.css" />' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above ^^
Thx for your CRs, fixed all the problems, still doesnt work with two or more swagger blocks on one page, ill research this problem later, something with js scripts |
moves injected_html to a class member. By doing this, we don't need to use regex to replace the dependencies
Summary
Added swagger plugin, that allows to insert a swagger block into a wiki page
Details
This plugin requires an URL with the .json openapi file. It provides such functions as authorization, sending requests, exploring api documentation and models.
You can test how it works with this swagger docs: https://petstore3.swagger.io/api/v3/openapi.json
I am not sure how it will work with two swagger blocks on one page, but i am going to add this functionality in future PRs.
Tested on windows (python 3.11) and Ubuntu Server (Docker build)
Checks
docs/<corresponding file>