Merge branch 'feature/RM-5311_Fix_Swagger_Caching' into 'master'

RM-5311 - Fix the caching of swagger files

See merge request !363
This commit is contained in:
Richard Smith
2017-06-22 10:38:55 +01:00

View File

@@ -1,10 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="cache-control" content="max-age=0"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT"/>
<meta http-equiv="pragma" content="no-cache"/>
<title>Alfresco Governance Services REST API Explorer</title>
<link rel="shortcut icon" href="https://cdn-www.alfresco.com/sites/www.alfresco.com/themes/alfrescodotcom/favicon.ico" />
<link rel="shortcut icon"
href="https://cdn-www.alfresco.com/sites/www.alfresco.com/themes/alfrescodotcom/favicon.ico"/>
<link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
@@ -13,11 +18,19 @@
<link href='css/alfresco.css' media='screen' rel='stylesheet' type='text/css'/>
<!-- Google Tag Manager -->
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-W4HV22');
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({
'gtm.start': new Date().getTime(),
event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-W4HV22');
</script>
<!-- End Google Tag Manager -->
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
@@ -44,15 +57,15 @@
url: "definitions/gs-core-api.yaml",
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
onComplete: function (swaggerApi, swaggerUi) {
$('pre code').each(function(i, e) {
$('pre code').each(function (i, e) {
hljs.highlightBlock(e)
});
addAuthorization();
},
onFailure: function(data) {
onFailure: function (data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
@@ -64,29 +77,42 @@
validatorUrl: null
});
function addAuthorization(){
var username = $('#input_username').val();
var password = $('#input_password').val();
if (username.trim() != "" && password.trim() != "") {
function addAuthorization() {
var cacheA = new SwaggerClient.ApiKeyAuthorization("If-Modified-Since", "Mon, 26 Jul 1997 05:00:00 GMT", "header"),
cacheB = new SwaggerClient.ApiKeyAuthorization("Cache-Control", "no-cache", "header"),
cacheC = new SwaggerClient.ApiKeyAuthorization("Pragma", "no-cache", "header"),
username = $('#input_username').val(),
password = $('#input_password').val();
if (username.trim() != "" && password.trim() != "")
{
var basicAuth = new SwaggerClient.PasswordAuthorization(username, password);
window.swaggerUi.api.clientAuthorizations.remove("basicAuth");
window.swaggerUi.api.clientAuthorizations.add("basicAuth", basicAuth);
log("authorization added: username = " + username + ", auth = " + basicAuth);
}
window.swaggerUi.api.clientAuthorizations.add("cacheA", cacheA);
window.swaggerUi.api.clientAuthorizations.add("cacheB", cacheB);
window.swaggerUi.api.clientAuthorizations.add("cacheC", cacheC);
}
$('#input_username').change(addAuthorization);
$('#input_password').change(addAuthorization);
window.swaggerUi.load();
$('#select_baseUrl').change(function() {
$('#select_baseUrl').change(function () {
window.swaggerUi.headerView.trigger('update-swagger-ui', {
url: $('#select_baseUrl').val()
});
});
function log() {
if ('console' in window) {
if ('console' in window)
{
console.log.apply(console, arguments);
}
}
@@ -96,19 +122,24 @@
<body class="swagger-section">
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W4HV22" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<noscript>
<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W4HV22" height="0" width="0"
style="display:none;visibility:hidden"></iframe>
</noscript>
<!-- End Google Tag Manager (noscript) -->
<div id='header'>
<div class="swagger-ui-wrap">
<a id="alflogo" href="#"><img src="images/logo.png" height="44px" width="160px" /></a>
<a id="alflogo" href="#"><img src="images/logo.png" height="44px" width="160px"/></a>
<form id="api_selector">
<div class="input" id="select-wrapper">
<select id="select_baseUrl" name="select_baseUrl">
<option value="definitions/gs-core-api.yaml">GS Core API</option>
</select>
</div>
<div class="input"><input alt="Username" type="text" name="username" id="input_username" placeholder="username" size="10" value="admin"></div>
<div class="input"><input alt="Password" type="password" name="password" id="input_password" placeholder="password" size="10" value="admin"></div>
<div class="input"><input alt="Username" type="text" name="username" id="input_username" placeholder="username"
size="10" value="admin"></div>
<div class="input"><input alt="Password" type="password" name="password" id="input_password"
placeholder="password" size="10" value="admin"></div>
</form>
</div>
</div>