Skip to content

Commit c5054f3

Browse files
committed
docs: host Swagger editor via GitHub pages
1 parent 2b6ccdb commit c5054f3

10 files changed

+148
-0
lines changed

docs/index.html

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!-- HTML for static distribution bundle build -->
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>Swagger UI</title>
7+
<link rel="stylesheet" type="text/css" href="./swagger-ui/swagger-ui.css" >
8+
<link rel="icon" type="image/png" href="./swagger-ui/favicon-32x32.png" sizes="32x32" />
9+
<link rel="icon" type="image/png" href="./swagger-ui/favicon-16x16.png" sizes="16x16" />
10+
<style>
11+
html
12+
{
13+
box-sizing: border-box;
14+
overflow: -moz-scrollbars-vertical;
15+
overflow-y: scroll;
16+
}
17+
18+
*,
19+
*:before,
20+
*:after
21+
{
22+
box-sizing: inherit;
23+
}
24+
25+
body
26+
{
27+
margin:0;
28+
background: #fafafa;
29+
}
30+
</style>
31+
</head>
32+
33+
<body>
34+
<div id="swagger-ui"></div>
35+
36+
<script src="./swagger-ui/swagger-ui-bundle.js" charset="UTF-8"> </script>
37+
<script src="./swagger-ui/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
38+
<script>
39+
window.onload = function() {
40+
// Begin Swagger UI call region
41+
const ui = SwaggerUIBundle({
42+
url: "./swagger.yaml",
43+
dom_id: '#swagger-ui',
44+
deepLinking: true,
45+
presets: [
46+
SwaggerUIBundle.presets.apis,
47+
SwaggerUIStandalonePreset
48+
],
49+
plugins: [
50+
SwaggerUIBundle.plugins.DownloadUrl
51+
],
52+
layout: "StandaloneLayout"
53+
})
54+
// End Swagger UI call region
55+
56+
window.ui = ui
57+
}
58+
</script>
59+
</body>
60+
</html>

docs/swagger-ui/favicon-16x16.png

665 Bytes
Loading

docs/swagger-ui/favicon-32x32.png

628 Bytes
Loading

docs/swagger-ui/oauth2-redirect.html

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!doctype html>
2+
<html lang="en-US">
3+
<head>
4+
<title>Swagger UI: OAuth2 Redirect</title>
5+
</head>
6+
<body>
7+
</body>
8+
</html>
9+
<script>
10+
'use strict';
11+
function run () {
12+
var oauth2 = window.opener.swaggerUIRedirectOauth2;
13+
var sentState = oauth2.state;
14+
var redirectUrl = oauth2.redirectUrl;
15+
var isValid, qp, arr;
16+
17+
if (/code|token|error/.test(window.location.hash)) {
18+
qp = window.location.hash.substring(1);
19+
} else {
20+
qp = location.search.substring(1);
21+
}
22+
23+
arr = qp.split("&")
24+
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
25+
qp = qp ? JSON.parse('{' + arr.join() + '}',
26+
function (key, value) {
27+
return key === "" ? value : decodeURIComponent(value)
28+
}
29+
) : {}
30+
31+
isValid = qp.state === sentState
32+
33+
if ((
34+
oauth2.auth.schema.get("flow") === "accessCode" ||
35+
oauth2.auth.schema.get("flow") === "authorizationCode" ||
36+
oauth2.auth.schema.get("flow") === "authorization_code"
37+
) && !oauth2.auth.code) {
38+
if (!isValid) {
39+
oauth2.errCb({
40+
authId: oauth2.auth.name,
41+
source: "auth",
42+
level: "warning",
43+
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
44+
});
45+
}
46+
47+
if (qp.code) {
48+
delete oauth2.state;
49+
oauth2.auth.code = qp.code;
50+
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
51+
} else {
52+
let oauthErrorMsg
53+
if (qp.error) {
54+
oauthErrorMsg = "["+qp.error+"]: " +
55+
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
56+
(qp.error_uri ? "More info: "+qp.error_uri : "");
57+
}
58+
59+
oauth2.errCb({
60+
authId: oauth2.auth.name,
61+
source: "auth",
62+
level: "error",
63+
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
64+
});
65+
}
66+
} else {
67+
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
68+
}
69+
window.close();
70+
}
71+
72+
window.addEventListener('DOMContentLoaded', function () {
73+
run();
74+
});
75+
</script>

docs/swagger-ui/swagger-ui-bundle.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/swagger-ui/swagger-ui-bundle.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/swagger-ui/swagger-ui-standalone-preset.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/swagger-ui/swagger-ui-standalone-preset.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/swagger-ui/swagger-ui.css

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/swagger-ui/swagger-ui.css.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)