Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
blueswen committed Jan 22, 2024
1 parent 175035a commit 663400d
Show file tree
Hide file tree
Showing 36 changed files with 105 additions and 102 deletions.
21 changes: 11 additions & 10 deletions demo-mkdocs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,40 @@
<a target="_blank" href="https://pypi.org/project/mkdocs-swagger-ui-tag"><img src="https://img.shields.io/pypi/dm/mkdocs-swagger-ui-tag.svg" alt="PyPI downloads"/></a>
<a target="_blank" href="https://codecov.io/gh/blueswen/mkdocs-swagger-ui-tag"><img src="https://codecov.io/gh/blueswen/mkdocs-swagger-ui-tag/branch/main/graph/badge.svg?token=1D1B0GAQN1" alt="Codecov"/></a>

A MkDocs plugin supports for add [Swagger UI](https://github.com/swagger-api/swagger-ui) in page.
A MkDocs plugin supports adding [Swagger UI](https://github.com/swagger-api/swagger-ui) to the page.

## Features

1. OpenAPI Specification file from online over URL or static file in docs
2. All dependencies are using static files handled by plugin not from CDN, especially suitable for those documents been deployed in the intranet
3. Multiple Swagger UI in same page
2. All dependencies are using static files handled by the plugin not from CDN, especially suitable for those documents been deployed in the intranet
3. Multiple Swagger UI on the same page
4. Synchronized dark mode with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/)
5. Configure [Swagger UI configuration](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/) through plugin options and tag attributes
6. Support multiple OAS in single Swagger UI with top bar selector
6. Support multiple OAS in a single Swagger UI with a top bar selector
7. Support Swagger UI [initOAuth](https://swagger.io/docs/open-source-tools/swagger-ui/usage/oauth2/) method

## Dependency

1. Python Package
1. beautifulsoup4>=4.11.1
2. [Swagger UI dist](https://www.npmjs.com/package/swagger-ui-dist) javascript file and css file
1. swagger-ui-dist==5.10.0
2. [Swagger UI dist](https://www.npmjs.com/package/swagger-ui-dist) javascript file and CSS file
1. swagger-ui-dist==5.11.0

## Usage

1. Install plugin from pypi
1. Install the plugin from PyPI

```bash
pip install mkdocs-swagger-ui-tag
```

2. Add ```swagger-ui-tag``` plugin in to your mkdocs.yml plugins sections:
2. Add ```swagger-ui-tag``` plugin to your mkdocs.yml plugins sections:

```yaml
plugins:
- swagger-ui-tag
```

3. Add ```swagger-ui``` tag in markdown to include Swagger UI

```html
Expand Down Expand Up @@ -66,8 +67,8 @@ A MkDocs plugin supports for add [Swagger UI](https://github.com/swagger-api/swa
## How it works
1. Copy Swagger UI script file into `site/assets/javascripts/` directory, CSS file into `site/assets/stylesheets/` directory, and the [default Oauth2 redirect html](https://github.com/blueswen/mkdocs-swagger-ui-tag/blob/main/mkdocs_swagger_ui_tag/swagger-ui/oauth2-redirect.html) into `site/assets/swagger-ui/` directory
2. Search all swagger-ui tags, then convert them to an iframe tag and generate the iframe target html with the given OpenAPI Specification src path and options
1. Copy the Swagger UI script file into `site/assets/javascripts/` directory, the CSS file into `site/assets/stylesheets/` directory, and the [default Oauth2 redirect html](https://github.com/blueswen/mkdocs-swagger-ui-tag/blob/main/mkdocs_swagger_ui_tag/swagger-ui/oauth2-redirect.html) into `site/assets/swagger-ui/` directory
2. Search all swagger-ui tags, then convert them to an iframe tag and generate the iframe target HTML with the given OpenAPI Specification src path and options
## License
Expand Down
6 changes: 3 additions & 3 deletions docs/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@


<link rel="icon" href="/mkdocs-swagger-ui-tag/assets/images/favicon.png">
<meta name="generator" content="mkdocs-1.5.3, mkdocs-material-9.4.6+insiders-4.42.2">
<meta name="generator" content="mkdocs-1.5.3, mkdocs-material-9.4.11+insiders-4.44.0">



<title>MkDocs Swagger UI Tag</title>



<link rel="stylesheet" href="/mkdocs-swagger-ui-tag/assets/stylesheets/main.62ccb7e6.min.css">
<link rel="stylesheet" href="/mkdocs-swagger-ui-tag/assets/stylesheets/main.0ab26e37.min.css">


<link rel="stylesheet" href="/mkdocs-swagger-ui-tag/assets/stylesheets/palette.ab4e12ef.min.css">
Expand Down Expand Up @@ -664,7 +664,7 @@ <h1>404 - Not found</h1>
<script id="__config" type="application/json">{"base": "/mkdocs-swagger-ui-tag/", "features": ["toc.integrate", "navigation.tabs"], "search": "/mkdocs-swagger-ui-tag/assets/javascripts/workers/search.1e90e0fb.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>


<script src="/mkdocs-swagger-ui-tag/assets/javascripts/bundle.59e7e423.min.js"></script>
<script src="/mkdocs-swagger-ui-tag/assets/javascripts/bundle.6981e6db.min.js"></script>


</body>
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/javascripts/swagger-ui-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/javascripts/swagger-ui-bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/javascripts/swagger-ui-standalone-preset.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/stylesheets/swagger-ui.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/stylesheets/swagger-ui.css.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/demo/build-in-multiple/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<link href="../multiple/" rel="prev"/>
<link href="../oauth2/" rel="next"/>
<link href="../../assets/images/favicon.png" rel="icon"/>
<meta content="mkdocs-1.5.3, mkdocs-material-9.4.6+insiders-4.42.2" name="generator"/>
<meta content="mkdocs-1.5.3, mkdocs-material-9.4.11+insiders-4.44.0" name="generator"/>
<title>Build-in Multiple - MkDocs Swagger UI Tag</title>
<link href="../../assets/stylesheets/main.62ccb7e6.min.css" rel="stylesheet"/>
<link href="../../assets/stylesheets/main.0ab26e37.min.css" rel="stylesheet"/>
<link href="../../assets/stylesheets/palette.ab4e12ef.min.css" rel="stylesheet"/>
<link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect"/>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&amp;display=fallback" rel="stylesheet"/>
Expand Down Expand Up @@ -383,13 +383,13 @@ <h2 id="markdown">Markdown</h2>
<a href="#__codelineno-0-11" id="__codelineno-0-11" name="__codelineno-0-11"></a><span class="p">&lt;</span><span class="nt">swagger-ui</span> <span class="na">src</span><span class="o">=</span><span class="s">"./openapi-spec/sample.yaml"</span><span class="p">/&gt;</span>
</code></pre></div>
<h2 id="multiple-oas-in-single-swagger-ui">Multiple OAS in single Swagger UI</h2>
<p><iframe class="swagger-ui-iframe" frameborder="0" id="e32d1a87" src="swagger-e32d1a87.html" style="overflow:hidden;width:100%;" width="100%"></iframe>
<p><iframe class="swagger-ui-iframe" frameborder="0" id="d231647c" src="swagger-d231647c.html" style="overflow:hidden;width:100%;" width="100%"></iframe>



</p>
<h2 id="other-independent-swagger-ui">Other independent Swagger UI</h2>
<p><iframe class="swagger-ui-iframe" frameborder="0" id="e798008e" src="swagger-e798008e.html" style="overflow:hidden;width:100%;" width="100%"></iframe></p>
<p><iframe class="swagger-ui-iframe" frameborder="0" id="36cd46eb" src="swagger-36cd46eb.html" style="overflow:hidden;width:100%;" width="100%"></iframe></p>
</article>
</div>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
Expand All @@ -414,7 +414,7 @@ <h2 id="other-independent-swagger-ui">Other independent Swagger UI</h2>
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"base": "../..", "features": ["toc.integrate", "navigation.tabs"], "search": "../../assets/javascripts/workers/search.1e90e0fb.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>
<script src="../../assets/javascripts/bundle.59e7e423.min.js"></script>
<script src="../../assets/javascripts/bundle.6981e6db.min.js"></script>
<script>document$.subscribe(() => {
window.update_swagger_ui_iframe_height = function (id) {
var iFrameID = document.getElementById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
}

const resize_ob = new ResizeObserver(function(entries) {
parent.update_swagger_ui_iframe_height("33c03007");
parent.update_swagger_ui_iframe_height("36cd46eb");
});

// start observing for resizing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
}

const resize_ob = new ResizeObserver(function(entries) {
parent.update_swagger_ui_iframe_height("e32d1a87");
parent.update_swagger_ui_iframe_height("d231647c");
});

// start observing for resizing
Expand Down
12 changes: 6 additions & 6 deletions docs/demo/multiple/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<link href="../pet-store-full-width/" rel="prev"/>
<link href="../build-in-multiple/" rel="next"/>
<link href="../../assets/images/favicon.png" rel="icon"/>
<meta content="mkdocs-1.5.3, mkdocs-material-9.4.6+insiders-4.42.2" name="generator"/>
<meta content="mkdocs-1.5.3, mkdocs-material-9.4.11+insiders-4.44.0" name="generator"/>
<title>Multiple - MkDocs Swagger UI Tag</title>
<link href="../../assets/stylesheets/main.62ccb7e6.min.css" rel="stylesheet"/>
<link href="../../assets/stylesheets/main.0ab26e37.min.css" rel="stylesheet"/>
<link href="../../assets/stylesheets/palette.ab4e12ef.min.css" rel="stylesheet"/>
<link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect"/>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&amp;display=fallback" rel="stylesheet"/>
Expand Down Expand Up @@ -360,9 +360,9 @@ <h2 id="markdown">Markdown</h2>
<a href="#__codelineno-0-3" id="__codelineno-0-3" name="__codelineno-0-3"></a><span class="p">&lt;</span><span class="nt">swagger-ui</span> <span class="na">src</span><span class="o">=</span><span class="s">"https://petstore.swagger.io/v2/swagger.json"</span><span class="p">/&gt;</span>
</code></pre></div>
<h2 id="swagger-ui">Swagger UI</h2>
<p><iframe class="swagger-ui-iframe" frameborder="0" id="33c03007" src="swagger-33c03007.html" style="overflow:hidden;width:100%;" width="100%"></iframe>
<iframe class="swagger-ui-iframe" frameborder="0" id="b3c64780" src="swagger-b3c64780.html" style="overflow:hidden;width:100%;" width="100%"></iframe>
<iframe class="swagger-ui-iframe" frameborder="0" id="9680a3b1" src="swagger-9680a3b1.html" style="overflow:hidden;width:100%;" width="100%"></iframe></p>
<p><iframe class="swagger-ui-iframe" frameborder="0" id="fd03eb78" src="swagger-fd03eb78.html" style="overflow:hidden;width:100%;" width="100%"></iframe>
<iframe class="swagger-ui-iframe" frameborder="0" id="5c49375b" src="swagger-5c49375b.html" style="overflow:hidden;width:100%;" width="100%"></iframe>
<iframe class="swagger-ui-iframe" frameborder="0" id="d37c5213" src="swagger-d37c5213.html" style="overflow:hidden;width:100%;" width="100%"></iframe></p>
</article>
</div>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
Expand All @@ -387,7 +387,7 @@ <h2 id="swagger-ui">Swagger UI</h2>
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"base": "../..", "features": ["toc.integrate", "navigation.tabs"], "search": "../../assets/javascripts/workers/search.1e90e0fb.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>
<script src="../../assets/javascripts/bundle.59e7e423.min.js"></script>
<script src="../../assets/javascripts/bundle.6981e6db.min.js"></script>
<script>document$.subscribe(() => {
window.update_swagger_ui_iframe_height = function (id) {
var iFrameID = document.getElementById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
}

const resize_ob = new ResizeObserver(function(entries) {
parent.update_swagger_ui_iframe_height("b3c64780");
parent.update_swagger_ui_iframe_height("5c49375b");
});

// start observing for resizing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
}

const resize_ob = new ResizeObserver(function(entries) {
parent.update_swagger_ui_iframe_height("f75140d9");
parent.update_swagger_ui_iframe_height("d37c5213");
});

// start observing for resizing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
}

const resize_ob = new ResizeObserver(function(entries) {
parent.update_swagger_ui_iframe_height("e3268f84");
parent.update_swagger_ui_iframe_height("fd03eb78");
});

// start observing for resizing
Expand Down
8 changes: 4 additions & 4 deletions docs/demo/oauth2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<link href="../build-in-multiple/" rel="prev"/>
<link href="../without-try-it-out/" rel="next"/>
<link href="../../assets/images/favicon.png" rel="icon"/>
<meta content="mkdocs-1.5.3, mkdocs-material-9.4.6+insiders-4.42.2" name="generator"/>
<meta content="mkdocs-1.5.3, mkdocs-material-9.4.11+insiders-4.44.0" name="generator"/>
<title>OAuth2 Initialization - MkDocs Swagger UI Tag</title>
<link href="../../assets/stylesheets/main.62ccb7e6.min.css" rel="stylesheet"/>
<link href="../../assets/stylesheets/main.0ab26e37.min.css" rel="stylesheet"/>
<link href="../../assets/stylesheets/palette.ab4e12ef.min.css" rel="stylesheet"/>
<link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect"/>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&amp;display=fallback" rel="stylesheet"/>
Expand Down Expand Up @@ -408,7 +408,7 @@ <h2 id="markdown">Markdown</h2>
<a href="#__codelineno-0-9" id="__codelineno-0-9" name="__codelineno-0-9"></a> <span class="na">usePkceWithAuthorizationCodeGrant</span><span class="o">=</span><span class="s">"false"</span><span class="p">/&gt;</span>
</code></pre></div>
<h2 id="swagger-ui">Swagger UI</h2>
<p><iframe class="swagger-ui-iframe" frameborder="0" id="4bcc89d8" src="swagger-4bcc89d8.html" style="overflow:hidden;width:100%;" width="100%"></iframe></p>
<p><iframe class="swagger-ui-iframe" frameborder="0" id="0e6e423e" src="swagger-0e6e423e.html" style="overflow:hidden;width:100%;" width="100%"></iframe></p>
</article>
</div>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
Expand All @@ -433,7 +433,7 @@ <h2 id="swagger-ui">Swagger UI</h2>
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"base": "../..", "features": ["toc.integrate", "navigation.tabs"], "search": "../../assets/javascripts/workers/search.1e90e0fb.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>
<script src="../../assets/javascripts/bundle.59e7e423.min.js"></script>
<script src="../../assets/javascripts/bundle.6981e6db.min.js"></script>
<script>document$.subscribe(() => {
window.update_swagger_ui_iframe_height = function (id) {
var iFrameID = document.getElementById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
}

const resize_ob = new ResizeObserver(function(entries) {
parent.update_swagger_ui_iframe_height("4bcc89d8");
parent.update_swagger_ui_iframe_height("0e6e423e");
});

// start observing for resizing
Expand Down
10 changes: 5 additions & 5 deletions docs/demo/openapi-v3.1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<link href="https://blueswen.github.io/mkdocs-swagger-ui-tag/demo/openapi-v3.1/" rel="canonical"/>
<link href="../without-try-it-out/" rel="prev"/>
<link href="../../assets/images/favicon.png" rel="icon"/>
<meta content="mkdocs-1.5.3, mkdocs-material-9.4.6+insiders-4.42.2" name="generator"/>
<meta content="mkdocs-1.5.3, mkdocs-material-9.4.11+insiders-4.44.0" name="generator"/>
<title>OpenAPI v3.1 - MkDocs Swagger UI Tag</title>
<link href="../../assets/stylesheets/main.62ccb7e6.min.css" rel="stylesheet"/>
<link href="../../assets/stylesheets/main.0ab26e37.min.css" rel="stylesheet"/>
<link href="../../assets/stylesheets/palette.ab4e12ef.min.css" rel="stylesheet"/>
<link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect"/>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&amp;display=fallback" rel="stylesheet"/>
Expand Down Expand Up @@ -358,8 +358,8 @@ <h2 id="markdown">Markdown</h2>
<a href="#__codelineno-0-2" id="__codelineno-0-2" name="__codelineno-0-2"></a><span class="p">&lt;</span><span class="nt">swagger-ui</span> <span class="na">src</span><span class="o">=</span><span class="s">"./openapi-spec/v3.1/webhook-example.yaml"</span><span class="p">/&gt;</span>
</code></pre></div>
<h2 id="swagger-ui">Swagger UI</h2>
<p><iframe class="swagger-ui-iframe" frameborder="0" id="44c1a4b3" src="swagger-44c1a4b3.html" style="overflow:hidden;width:100%;" width="100%"></iframe></p>
<p><iframe class="swagger-ui-iframe" frameborder="0" id="8e3e32ee" src="swagger-8e3e32ee.html" style="overflow:hidden;width:100%;" width="100%"></iframe></p>
<p><iframe class="swagger-ui-iframe" frameborder="0" id="f330f398" src="swagger-f330f398.html" style="overflow:hidden;width:100%;" width="100%"></iframe></p>
<p><iframe class="swagger-ui-iframe" frameborder="0" id="deaa96ce" src="swagger-deaa96ce.html" style="overflow:hidden;width:100%;" width="100%"></iframe></p>
</article>
</div>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
Expand All @@ -384,7 +384,7 @@ <h2 id="swagger-ui">Swagger UI</h2>
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"base": "../..", "features": ["toc.integrate", "navigation.tabs"], "search": "../../assets/javascripts/workers/search.1e90e0fb.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>
<script src="../../assets/javascripts/bundle.59e7e423.min.js"></script>
<script src="../../assets/javascripts/bundle.6981e6db.min.js"></script>
<script>document$.subscribe(() => {
window.update_swagger_ui_iframe_height = function (id) {
var iFrameID = document.getElementById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
}

const resize_ob = new ResizeObserver(function(entries) {
parent.update_swagger_ui_iframe_height("8e3e32ee");
parent.update_swagger_ui_iframe_height("deaa96ce");
});

// start observing for resizing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
}

const resize_ob = new ResizeObserver(function(entries) {
parent.update_swagger_ui_iframe_height("44c1a4b3");
parent.update_swagger_ui_iframe_height("f330f398");
});

// start observing for resizing
Expand Down
Loading

0 comments on commit 663400d

Please sign in to comment.