/
swagger-ui.html
81 lines (75 loc) · 3.07 KB
/
swagger-ui.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
<!DOCTYPE html>
<html>
<head>
<title>{{ title }}</title>
{% include 'swagger-ui-css.html' %}
{% include 'swagger-ui-libs.html' %}
<script type="text/javascript">
// NOTE: `onOAuthComplete` implementation is extracted from the deprecated swagger-ui/lib/swagger-oauth.js
onOAuthComplete = function onOAuthComplete(token, OAuthSchemeKey) {
if (token === '') {
alert("Authorization failed for unknown reason, please, check your credentials!")
return
}
if(token.error) {
var checkbox = $('input[type=checkbox],.secured')
checkbox.each(function(pos) {
checkbox[pos].checked = false
})
alert(token.error)
}
else {
var access_token = token[window.swaggerUiAuth.tokenName]
if (!OAuthSchemeKey) {
OAuthSchemeKey = token.state;
}
if(access_token) {
// if all roles are satisfied
window.swaggerUi.api.clientAuthorizations.add(OAuthSchemeKey, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + access_token, 'header'))
window.swaggerUi.load()
}
}
}
$(function () {
window.swaggerUi = new SwaggerUi({
url: "{{ specs_url }}",
validatorUrl: "{{ config.SWAGGER_VALIDATOR_URL }}" || null,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch', 'options'],
onComplete: function(swaggerApi, swaggerUi){
if(typeof initOAuth == "function") {
{% if config.SWAGGER_UI_OAUTH_CLIENT_ID -%}
initOAuth({
clientId: "{{ config.SWAGGER_UI_OAUTH_CLIENT_ID }}",
realm: "{{ config.SWAGGER_UI_OAUTH_REALM }}",
appName: "{{ config.SWAGGER_UI_OAUTH_APP_NAME }}"
});
{%- endif %}
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
jsonEditor: {{ config.SWAGGER_UI_JSONEDITOR | default(False) | string | lower }},
docExpansion: "{{ config.SWAGGER_UI_DOC_EXPANSION | default('none') }}"
});
window.swaggerUi.load();
});
</script>
</head>
<body class="swagger-section">
<div id="header">
<div class="swagger-ui-wrap">
<a id="logo"><span class="logo__title">Flask-RESTplus Example API</span></a>
<form id="api_selector">
<div id="auth_container"></div>
</form>
</div>
</div>
<div id="message-bar" class="swagger-ui-wrap"> </div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>