|
1 | 1 | # MkDocs Swagger UI Tag |
2 | 2 |
|
3 | | -[](https://pypi.org/project/mkdocs-swagger-ui-tag) |
4 | | -[](https://pypi.org/project/mkdocs-swagger-ui-tag) |
| 3 | +<p align="center"> |
| 4 | +<a target="_blank" href="https://pypi.org/project/mkdocs-swagger-ui-tag"><img src="https://img.shields.io/pypi/v/mkdocs-swagger-ui-tag.svg" alt="PyPI version"/></a> |
| 5 | +<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> |
| 6 | +<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> |
| 7 | +</p> |
5 | 8 |
|
6 | 9 | A MkDocs plugin supports for add [Swagger UI](https://github.com/swagger-api/swagger-ui) in page. |
7 | 10 |
|
8 | 11 | [Live demo](https://blueswen.github.io/mkdocs-swagger-ui-tag/) with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/). |
9 | 12 |
|
10 | 13 | ## Features |
11 | 14 |
|
12 | | -1. OpenAPI Specification file from online over URL or static file in docs |
13 | | -2. Multiple Swagger UI in same page |
14 | | -3. Synchronized dark mode with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) |
15 | | -4. Configure [Swagger UI configuration](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/) through plugin options and tag attributes |
16 | | -5. Support multiple OAS in single Swagger UI with top bar selector |
17 | | -6. Support Swagger UI [initOAuth](https://swagger.io/docs/open-source-tools/swagger-ui/usage/oauth2/) method |
| 15 | +1. OpenAPI Specification file from online over URL or static file in docs |
| 16 | +2. All dependencies are using static files handled by plugin not from CDN, especially suitable for those documents been deployed in the intranet |
| 17 | +3. Multiple Swagger UI in same page |
| 18 | +4. Synchronized dark mode with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) |
| 19 | +5. Configure [Swagger UI configuration](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/) through plugin options and tag attributes |
| 20 | +6. Support multiple OAS in single Swagger UI with top bar selector |
| 21 | +7. Support Swagger UI [initOAuth](https://swagger.io/docs/open-source-tools/swagger-ui/usage/oauth2/) method |
18 | 22 |
|
19 | 23 | ## Dependency |
20 | 24 |
|
@@ -58,16 +62,22 @@ A MkDocs plugin supports for add [Swagger UI](https://github.com/swagger-api/swa |
58 | 62 | tryItOutEnabled: ['get', 'post'] |
59 | 63 | ``` |
60 | 64 |
|
61 | | - | Options | Type | Description | |
62 | | - |------------------------|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
63 | | - | background | String | Default: "". Swagger UI iframe body background attribute value. You can use any css value for background for example "#74b9ff" or "Gainsboro" or "" for nothing. | |
64 | | - | docExpansion | String | Default: "list". Controls the default expansion setting for the operations and tags. It can be "list" (expands only the tags), "full" (expands the tags and operations) or "none" (expands nothing). | |
65 | | - | filter | String or Boolean | Default: False. If set, enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. Can be Boolean to enable or disable, or a string, in which case filtering will be enabled using that string as the filter expression. Filtering is case sensitive matching the filter expression anywhere inside the tag. | |
66 | | - | syntaxHighlightTheme | String | Default: "agate". [Highlight.js](https://highlightjs.org/static/demo/) syntax coloring theme to use. It can be "agate", "arta", "monokai", "nord", "obsidian" or "tomorrow-night" | |
67 | | - | tryItOutEnabled | Boolean | Default: False. Controls whether the "Try it out" section should be enabled by default. | |
68 | | - | oauth2RedirectUrl | String | Default: Absolute URL of "/assets/swagger-ui/oauth2-redirect.html" relative with site_url in mkdocs.yml or document root path on site without site_url, e.g. "[https://blueswen.github.io/mkdocs-swagger-ui-tag/assets/swagger-ui/oauth2-redirect.html](https://blueswen.github.io/mkdocs-swagger-ui-tag/assets/swagger-ui/oauth2-redirect.html)". OAuth redirect URL. | |
69 | | - | supportedSubmitMethods | Array | Default: All Http Methods. Array=["get", "put", "post", "delete", "options", "head", "patch", "trace"]. List of HTTP methods that have the "Try it out" feature enabled. An empty array disables "Try it out" for all operations. This does not filter the operations from the display. | |
70 | | - | validatorUrl | String | Default: "https://validator.swagger.io/validator". By default, Swagger UI attempts to validate specs against swagger.io's online validator in multiple OAS Swagger UI. You can use this parameter to set a different validator URL, for example for locally deployed validators ([Validator Badge](https://github.com/swagger-api/validator-badge)). Setting it "none" to disable validation. | |
| 65 | + | Options | Type | Description | |
| 66 | + |---|---|---| |
| 67 | + | background | String | Default: "". Swagger UI iframe body background attribute value. You can use any css value for background for example "#74b9ff" or "Gainsboro" or "" for nothing. | |
| 68 | + | docExpansion | String | Default: "list". Controls the default expansion setting for the operations and tags. It can be "list" (expands only the tags), "full" (expands the tags and operations) or "none" (expands nothing). | |
| 69 | + | filter | String or Boolean | Default: False. If set, enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. Can be Boolean to enable or disable, or a string, in which case filtering will be enabled using that string as the filter expression. Filtering is case sensitive matching the filter expression anywhere inside the tag. | |
| 70 | + | syntaxHighlightTheme | String | Default: "agate". [Highlight.js](https://highlightjs.org/static/demo/) syntax coloring theme to use. It can be "agate", "arta", "monokai", "nord", "obsidian" or "tomorrow-night" | |
| 71 | + | tryItOutEnabled | Boolean | Default: False. Controls whether the "Try it out" section should be enabled by default. | |
| 72 | + | oauth2RedirectUrl | String | Default: Absolute URL of "/assets/swagger-ui/oauth2-redirect.html" relative with site_url in mkdocs.yml or document root path on site without site_url, e.g. "[https://blueswen.github.io/mkdocs-swagger-ui-tag/assets/swagger-ui/oauth2-redirect.html](https://blueswen.github.io/mkdocs-swagger-ui-tag/assets/swagger-ui/oauth2-redirect.html)". OAuth redirect URL. | |
| 73 | + | supportedSubmitMethods | Array | Default: All Http Methods. Array=["get", "put", "post", "delete", "options", "head", "patch", "trace"]. List of HTTP methods that have the "Try it out" feature enabled. An empty array disables "Try it out" for all operations. This does not filter the operations from the display. | |
| 74 | + | validatorUrl | String | Default: "none". By default, the validation is disabled. When setting with "https://validator.swagger.io/validator", Swagger UI attempts to validate specs against swagger.io's online validator in multiple OAS Swagger UI. You can use this parameter to set a different validator URL, for example for locally deployed validators ([Validator Badge](https://github.com/swagger-api/validator-badge)). | |
| 75 | + | extra_css | Array | Default: []. Extra CSS files included in Swagger UI iframe target html file. | |
| 76 | +
|
| 77 | +## How it works |
| 78 | +
|
| 79 | +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 |
| 80 | +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 |
71 | 81 |
|
72 | 82 | ## License |
73 | 83 |
|
|
0 commit comments