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

Added swagger plugin #162

Merged
merged 3 commits into from
Jun 1, 2024
Merged

Added swagger plugin #162

merged 3 commits into from
Jun 1, 2024

Conversation

DanZ-ix
Copy link
Contributor

@DanZ-ix DanZ-ix commented May 28, 2024

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

  • In case of new feature, add short overview in docs/<corresponding file>
  • Tested changes

Copy link
Owner

@Linbreux Linbreux left a 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.


injected_html = """
<div id="{id}"></div>
<script src="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui-bundle.js" crossorigin></script>
Copy link
Owner

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


class Plugin:
def import_head(self):
return '<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui.css" />'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above ^^

@DanZ-ix
Copy link
Contributor Author

DanZ-ix commented May 29, 2024

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

@DanZ-ix DanZ-ix requested a review from Linbreux May 29, 2024 17:08
moves injected_html to a class member. By doing this, we don't need to
use regex to replace the dependencies
@Linbreux Linbreux merged commit 6d033e0 into Linbreux:main Jun 1, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants