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> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <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> <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/typography.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/reset.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'/> <link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
@@ -13,10 +18,18 @@
<link href='css/alfresco.css' media='screen' rel='stylesheet' type='text/css'/> <link href='css/alfresco.css' media='screen' rel='stylesheet' type='text/css'/>
<!-- Google Tag Manager --> <!-- Google Tag Manager -->
<script> <script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': (function (w, d, s, l, i) {
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], w[l] = w[l] || [];
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= w[l].push({
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); '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'); })(window, document, 'script', 'dataLayer', 'GTM-W4HV22');
</script> </script>
<!-- End Google Tag Manager --> <!-- End Google Tag Manager -->
@@ -65,15 +78,27 @@
}); });
function addAuthorization() { function addAuthorization() {
var username = $('#input_username').val();
var password = $('#input_password').val(); var cacheA = new SwaggerClient.ApiKeyAuthorization("If-Modified-Since", "Mon, 26 Jul 1997 05:00:00 GMT", "header"),
if (username.trim() != "" && password.trim() != "") { 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); var basicAuth = new SwaggerClient.PasswordAuthorization(username, password);
window.swaggerUi.api.clientAuthorizations.remove("basicAuth"); window.swaggerUi.api.clientAuthorizations.remove("basicAuth");
window.swaggerUi.api.clientAuthorizations.add("basicAuth", basicAuth); window.swaggerUi.api.clientAuthorizations.add("basicAuth", basicAuth);
log("authorization added: username = " + username + ", auth = " + 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_username').change(addAuthorization);
$('#input_password').change(addAuthorization); $('#input_password').change(addAuthorization);
@@ -86,7 +111,8 @@
}); });
function log() { function log() {
if ('console' in window) { if ('console' in window)
{
console.log.apply(console, arguments); console.log.apply(console, arguments);
} }
} }
@@ -96,7 +122,10 @@
<body class="swagger-section"> <body class="swagger-section">
<!-- Google Tag Manager (noscript) --> <!-- 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) --> <!-- End Google Tag Manager (noscript) -->
<div id='header'> <div id='header'>
<div class="swagger-ui-wrap"> <div class="swagger-ui-wrap">
@@ -107,8 +136,10 @@
<option value="definitions/gs-core-api.yaml">GS Core API</option> <option value="definitions/gs-core-api.yaml">GS Core API</option>
</select> </select>
</div> </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="Username" type="text" name="username" id="input_username" placeholder="username"
<div class="input"><input alt="Password" type="password" name="password" id="input_password" placeholder="password" size="10" value="admin"></div> 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> </form>
</div> </div>
</div> </div>