Skip to content

Commit

Permalink
Replace static Swagger-ui distribution with unpkg version (#1604)
Browse files Browse the repository at this point in the history
  • Loading branch information
theletterf committed Jul 12, 2023
1 parent be2a0ff commit 92674f8
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 167 deletions.
3 changes: 3 additions & 0 deletions assets/scss/_swagger.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.swagger-ui .info .title small pre {
background: #7d8492;
}
2 changes: 2 additions & 0 deletions assets/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
@import "taxonomy";
@import "drawio";
@import "shortcodes";
@import "swagger";


@if $td-enable-google-fonts {
@import url($web-font-path);
Expand Down
4 changes: 2 additions & 2 deletions layouts/shortcodes/swaggerui.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{ $original := .Get "src" }}
<div id="ohpen_swagger_ui"></div>
<div id="docsy_swagger_ui"></div>
<script>
window.onload = function () {
const ui = SwaggerUIBundle({
url: {{ $original | relURL }},
dom_id: '#ohpen_swagger_ui',
dom_id: '#docsy_swagger_ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
Expand Down
6 changes: 3 additions & 3 deletions layouts/swagger/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
{{ partial "head.html" . }}
<title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} | {{ end }}{{ .Site.Title }}{{ end }}</title>
<link rel="stylesheet" type="text/css" href="{{ "css/swagger-ui.css" | relURL }}">
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5.1.0/swagger-ui.css" integrity="sha384-4cTBOIJxihgy9mISVlGqdBZkd66byHFwoLscqza6swXPIp5qiLBwuzuJD9cMjYOw" crossorigin="anonymous">
</head>
<body class="td-{{ .Kind }}">
<header>
Expand All @@ -22,8 +22,8 @@
</aside>
<main class="col-12 col-md-9 col-xl-8 ps-md-5" role="main">
{{ if not .Site.Params.ui.breadcrumb_disable }}{{ partial "breadcrumb.html" . }}{{ end }}
<script src="{{ "js/swagger-ui-bundle.js" | relURL }}"></script>
<script src="{{ "js/swagger-ui-standalone-preset.js" | relURL }}"></script>
<script src="https://unpkg.com/swagger-ui-dist@5.1.0/swagger-ui-bundle.js" integrity="sha384-TBW5qg/G561aZRk4jvscdaB7BEDK/9wpe/jS8vyKzK/ls+nJfWQw0W4cobLRYkWk" crossorigin="anonymous"></script>
<script src="https://unpkg.com/swagger-ui-dist@5.1.0/swagger-ui-standalone-preset.js" integrity="sha384-cftHzufgeQ3yLXAwNPSMCBSqPUkItABWOchc20veg7pQ1sDu0FQSp0Grfx/BfhN7" crossorigin="anonymous"></script>
{{ block "main" . }}{{ end }}
</main>
</div>
Expand Down
4 changes: 0 additions & 4 deletions static/css/swagger-ui.css

This file was deleted.

134 changes: 0 additions & 134 deletions static/js/swagger-ui-bundle.js

This file was deleted.

22 changes: 0 additions & 22 deletions static/js/swagger-ui-standalone-preset.js

This file was deleted.

4 changes: 2 additions & 2 deletions userguide/content/en/docs/adding-content/shortcodes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ resources:

### swaggerui

The `swaggerui` shortcode can be placed anywhere inside a page with the [`swagger` layout](https://github.com/google/docsy/tree/main/layouts/swagger); it renders [Swagger UI](https://swagger.io/tools/swagger-ui/) using any OpenAPI YAML or JSON file as source. This file can be hosted anywhere you like, for example in your site's root [`/static` folder](/docs/adding-content/content/#adding-static-content).
You can place the `swaggerui` shortcode anywhere inside a page with the [`swagger` layout](https://github.com/google/docsy/tree/main/layouts/swagger); it renders [Swagger UI](https://swagger.io/tools/swagger-ui/) using any OpenAPI YAML or JSON file as source. This file can be hosted anywhere you like, for example in your site's root [`/static` folder](/docs/adding-content/content/#adding-static-content).

{{< tabpane >}}
{{< tab header="Front matter:" disabled=true />}}
Expand Down Expand Up @@ -284,7 +284,7 @@ description: Reference for the Pet Store API
{{< /tab >}}
{{< /tabpane >}}

You can customize Swagger UI's look and feel by overriding Swagger's CSS or by editing and compiling a [Swagger UI dist](https://github.com/swagger-api/swagger-ui) yourself and replace `themes/docsy/static/css/swagger-ui.css`.
You can customize Swagger UI's look and feel by overriding Swagger's CSS in `themes/docsy/assets/scss/_swagger.scss`.

### redoc

Expand Down

0 comments on commit 92674f8

Please sign in to comment.