-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
125 lines (105 loc) · 4.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
<link rel="stylesheet" type="text/css" href="index.css" />
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
</head>
<body>
<div id="swagger-ui"></div>
<script src="./swagger-ui-bundle.js" charset="UTF-8"></script>
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"></script>
<script src="./emby-custom.js"></script>
<script src="./emby-auth.js"></script>
<script>
window.onload = function () {
function getWindowLocationSearch(win) {
'use strict';
var search = (win || window).location.search;
if (!search) {
var index = window.location.href.indexOf('?');
if (index !== -1) {
search = window.location.href.substring(index);
}
}
return search || '';
}
function getParameterByName(name, url) {
'use strict';
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS, "i");
var results = regex.exec(url || getWindowLocationSearch());
if (results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
function preauthorizeApiKey(system, key, value) {
const {
authActions: { authorize },
specSelectors: { specJson, isOAS3 }
} = system;
const definitionBase = isOAS3() ? ["components", "securitySchemes"] : ["securityDefinitions"];
const schema = specJson().getIn([...definitionBase, key]);
if (!schema) {
return null;
}
return authorize({
[key]: {
value,
schema: schema.toJS()
}
});
}
var apikey = getParameterByName('api_key');
// Create Configuration
const config = {
url: getParameterByName('url') || "http://localhost:8096/openapi",
dom_id: '#swagger-ui',
deepLinking: true,
defaultModelRendering: 'model',
docExpansion: 'none',
tagsSorter: 'alpha',
showExtensions: false,
filter: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl,
caseInsensitivePhraseFilter,
renderPrimitive,
renderEnum,
renderArray,
renderHttpAuth,
renderAuths
],
layout: 'StandaloneLayout',
onComplete: function () {
if (apikey && apikey.trim() !== '') {
preauthorizeApiKey(ui, 'apikeyauth', apikey);
}
}
}
if (getParameterByName('staticview')) {
config.plugins = [
caseInsensitivePhraseFilter, disableAuthorizePlugin, hideTopbarPlugin,
renderPrimitive, renderEnum, renderArray
];
config.url = 'openapi.json';
config.supportedSubmitMethods = [];
apikey = null;
}
// Build a system
const ui = SwaggerUIBundle(config);
window.ui = ui;
}
</script>
</body>
</html>