Commit 5c2cd004 authored by nikhiljindal's avatar nikhiljindal

Updating swagger-ui to the latest version

parent 8278928b
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -13,9 +13,8 @@ Instructions on how to use these: ...@@ -13,9 +13,8 @@ Instructions on how to use these:
https://github.com/swagger-api/swagger-ui#how-to-use-it https://github.com/swagger-api/swagger-ui#how-to-use-it
## Local Modifications ## Local Modifications
- Updated the url to "../../swaggerapi" as per instructions at: - Updated the url in index.html to "../../swaggerapi" as per instructions at:
https://github.com/swagger-api/swagger-ui#how-to-use-it https://github.com/swagger-api/swagger-ui#how-to-use-it
- Modified swagger-ui.js to list resources and operations in sorted order.
- Set supportedSubmitMethods: [] in index.html to remove "Try it out" buttons. - Set supportedSubmitMethods: [] in index.html to remove "Try it out" buttons.
LICENSE file has been created for compliance purposes. LICENSE file has been created for compliance purposes.
......
...@@ -274,6 +274,9 @@ ...@@ -274,6 +274,9 @@
font-weight: bold; font-weight: bold;
font-size: 25px; font-size: 25px;
} }
.swagger-section .swagger-ui-wrap .footer {
margin-top: 20px;
}
.swagger-section .swagger-ui-wrap p.big, .swagger-section .swagger-ui-wrap p.big,
.swagger-section .swagger-ui-wrap div.big p { .swagger-section .swagger-ui-wrap div.big p {
font-size: 1em; font-size: 1em;
...@@ -423,6 +426,17 @@ ...@@ -423,6 +426,17 @@
.swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper .optionName { .swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper .optionName {
font-weight: bold; font-weight: bold;
} }
.swagger-section .swagger-ui-wrap .model-signature .description .propDesc.markdown > p:first-child,
.swagger-section .swagger-ui-wrap .model-signature .description .propDesc.markdown > p:last-child {
display: inline;
}
.swagger-section .swagger-ui-wrap .model-signature .description .propDesc.markdown > p:not(:first-child):before {
display: block;
content: '';
}
.swagger-section .swagger-ui-wrap .model-signature .description span:last-of-type.propDesc.markdown > p:only-child {
margin-right: -3px;
}
.swagger-section .swagger-ui-wrap .model-signature .propName { .swagger-section .swagger-ui-wrap .model-signature .propName {
font-weight: bold; font-weight: bold;
} }
...@@ -1066,6 +1080,9 @@ ...@@ -1066,6 +1080,9 @@
.swagger-section .swagger-ui-wrap form.form_box p strong { .swagger-section .swagger-ui-wrap form.form_box p strong {
color: black; color: black;
} }
.swagger-section .swagger-ui-wrap .operation-status td.markdown > p:last-child {
padding-bottom: 0;
}
.swagger-section .title { .swagger-section .title {
font-style: bold; font-style: bold;
} }
......
.swagger-section #header a#logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
background: transparent url(../images/logo.png) no-repeat left center;
padding: 20px 0 20px 40px;
}
#text-head {
font-size: 80px;
font-family: 'Roboto', sans-serif;
color: #ffffff;
float: right;
margin-right: 20%;
}
.navbar-fixed-top .navbar-nav {
height: auto;
}
.navbar-fixed-top .navbar-brand {
height: auto;
}
.navbar-header {
height: auto;
}
.navbar-inverse {
background-color: #000;
border-color: #000;
}
#navbar-brand {
margin-left: 20%;
}
.navtext {
font-size: 10px;
}
.h1,
h1 {
font-size: 60px;
}
.navbar-default .navbar-header .navbar-brand {
color: #a2dfee;
}
/* tag titles */
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a {
color: #393939;
font-family: 'Arvo', serif;
font-size: 1.5em;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover {
color: black;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 {
color: #525252;
padding-left: 0px;
display: block;
clear: none;
float: left;
font-family: 'Arvo', serif;
font-weight: bold;
}
.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
border-color: #0A0A0A;
}
.container1 {
width: 1500px;
margin: auto;
margin-top: 0;
background-image: url('../images/shield.png');
background-repeat: no-repeat;
background-position: -40px -20px;
margin-bottom: 210px;
}
.container-inner {
width: 1200px;
margin: auto;
background-color: rgba(223, 227, 228, 0.75);
padding-bottom: 40px;
padding-top: 40px;
border-radius: 15px;
}
.header-content {
padding: 0;
width: 1000px;
}
.title1 {
font-size: 80px;
font-family: 'Vollkorn', serif;
color: #404040;
text-align: center;
padding-top: 40px;
padding-bottom: 100px;
}
#icon {
margin-top: -18px;
}
.subtext {
font-size: 25px;
font-style: italic;
color: #08b;
text-align: right;
padding-right: 250px;
}
.bg-primary {
background-color: #00468b;
}
.navbar-default .nav > li > a,
.navbar-default .nav > li > a:focus {
color: #08b;
}
.navbar-default .nav > li > a,
.navbar-default .nav > li > a:hover {
color: #08b;
}
.navbar-default .nav > li > a,
.navbar-default .nav > li > a:focus:hover {
color: #08b;
}
.text-faded {
font-size: 25px;
font-family: 'Vollkorn', serif;
}
.section-heading {
font-family: 'Vollkorn', serif;
font-size: 45px;
padding-bottom: 10px;
}
hr {
border-color: #00468b;
padding-bottom: 10px;
}
.description {
margin-top: 20px;
padding-bottom: 200px;
}
.description li {
font-family: 'Vollkorn', serif;
font-size: 25px;
color: #525252;
margin-left: 28%;
padding-top: 5px;
}
.gap {
margin-top: 200px;
}
.troubleshootingtext {
color: rgba(255, 255, 255, 0.7);
padding-left: 30%;
}
.troubleshootingtext li {
list-style-type: circle;
font-size: 25px;
padding-bottom: 5px;
}
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1000;
}
.block.response_body.json:hover {
cursor: pointer;
}
.backdrop {
color: blue;
}
#myModal {
height: 100%;
}
.modal-backdrop {
bottom: 0;
position: fixed;
}
.curl {
padding: 10px;
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
font-size: 0.9em;
max-height: 400px;
margin-top: 5px;
overflow-y: auto;
background-color: #fcf6db;
border: 1px solid #e5e0c6;
border-radius: 4px;
}
.curl_title {
font-size: 1.1em;
margin: 0;
padding: 15px 0 5px;
font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
font-weight: 500;
line-height: 1.1;
}
.footer {
display: none;
}
.swagger-section .swagger-ui-wrap h2 {
padding: 0;
}
h2 {
margin: 0;
margin-bottom: 5px;
}
.markdown p {
font-size: 15px;
font-family: 'Arvo', serif;
}
.swagger-section .swagger-ui-wrap .code {
font-size: 15px;
font-family: 'Arvo', serif;
}
.swagger-section .swagger-ui-wrap b {
font-family: 'Arvo', serif;
}
#signin:hover {
cursor: pointer;
}
.dropdown-menu {
padding: 15px;
}
.navbar-right .dropdown-menu {
left: 0;
right: auto;
}
#signinbutton {
width: 100%;
height: 32px;
font-size: 13px;
font-weight: bold;
color: #08b;
}
.navbar-default .nav > li .details {
color: #000000;
text-transform: none;
font-size: 15px;
font-weight: normal;
font-family: 'Open Sans', sans-serif;
font-style: italic;
line-height: 20px;
top: -2px;
}
.navbar-default .nav > li .details:hover {
color: black;
}
#signout {
width: 100%;
height: 32px;
font-size: 13px;
font-weight: bold;
color: #08b;
}
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Swagger UI</title> <title>Swagger UI</title>
<link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/> <link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32" />
<link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/> <link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
<link href='css/screen.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='print' rel='stylesheet' type='text/css'/> <link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/screen.css' media='print' rel='stylesheet' type='text/css'/> <link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
<script type="text/javascript" src="lib/shred.bundle.js"></script> <link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script> <link href='css/print.css' media='print' rel='stylesheet' type='text/css'/>
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script> <script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script> <script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
<script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script> <script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
<script src='lib/handlebars-2.0.0.js' type='text/javascript'></script> <script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
<script src='lib/underscore-min.js' type='text/javascript'></script> <script src='lib/handlebars-2.0.0.js' type='text/javascript'></script>
<script src='lib/backbone-min.js' type='text/javascript'></script> <script src='lib/underscore-min.js' type='text/javascript'></script>
<script src='lib/swagger-client.js' type='text/javascript'></script> <script src='lib/backbone-min.js' type='text/javascript'></script>
<script src='swagger-ui.js' type='text/javascript'></script> <script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script> <script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
<script src='lib/marked.js' type='text/javascript'></script> <script src='lib/marked.js' type='text/javascript'></script>
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
<!-- enabling this will enable oauth2 implicit scope support -->
<script src='lib/swagger-oauth.js' type='text/javascript'></script> <script type="text/javascript">
<script type="text/javascript"> $(function () {
$(function () { var url = window.location.search.match(/url=([^&]+)/);
var url = window.location.search.match(/url=([^&]+)/); if (url && url.length > 1) {
if (url && url.length > 1) { url = decodeURIComponent(url[1]);
url = decodeURIComponent(url[1]); } else {
} else { url = "../../swaggerapi";
url = "../../swaggerapi"; }
} window.swaggerUi = new SwaggerUi({
window.swaggerUi = new SwaggerUi({ url: url,
url: url, dom_id: "swagger-ui-container",
dom_id: "swagger-ui-container", supportedSubmitMethods: [],
supportedSubmitMethods: [], onComplete: function(swaggerApi, swaggerUi){
onComplete: function(swaggerApi, swaggerUi){ if(typeof initOAuth == "function") {
if(typeof initOAuth == "function") { initOAuth({
/* clientId: "your-client-id",
initOAuth({ realm: "your-realms",
clientId: "your-client-id", appName: "your-app-name"
realm: "your-realms", });
appName: "your-app-name" }
});
*/ $('pre code').each(function(i, e) {
} hljs.highlightBlock(e)
$('pre code').each(function(i, e) { });
hljs.highlightBlock(e)
}); addApiKeyAuthorization();
}, },
onFailure: function(data) { onFailure: function(data) {
log("Unable to Load SwaggerUI"); log("Unable to Load SwaggerUI");
}, },
docExpansion: "none", docExpansion: "none",
sorter : "alpha" apisSorter: "alpha",
}); showRequestHeaders: false
});
function addApiKeyAuthorization() {
var key = $('#input_apiKey')[0].value; function addApiKeyAuthorization(){
log("key: " + key); var key = encodeURIComponent($('#input_apiKey')[0].value);
if(key && key.trim() != "") { if(key && key.trim() != "") {
log("added key " + key); var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("api_key", key, "query");
window.authorizations.add("api_key", new ApiKeyAuthorization("api_key", key, "query")); window.swaggerUi.api.clientAuthorizations.add("api_key", apiKeyAuth);
} log("added key " + key);
} }
}
$('#input_apiKey').change(function() {
addApiKeyAuthorization(); $('#input_apiKey').change(addApiKeyAuthorization);
});
// if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
// if you have an apiKey you would like to pre-populate on the page for demonstration purposes... /*
/* var apiKey = "myApiKeyXXXX123456789";
var apiKey = "myApiKeyXXXX123456789"; $('#input_apiKey').val(apiKey);
$('#input_apiKey').val(apiKey); */
addApiKeyAuthorization();
*/ window.swaggerUi.load();
window.swaggerUi.load(); function log() {
}); if ('console' in window) {
</script> console.log.apply(console, arguments);
</head> }
}
<body class="swagger-section"> });
<div id='header'> </script>
<div class="swagger-ui-wrap"> </head>
<a id="logo" href="http://swagger.io">swagger</a>
<form id='api_selector'> <body class="swagger-section">
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div> <div id='header'>
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div> <div class="swagger-ui-wrap">
<div class='input'><a id="explore" href="#">Explore</a></div> <a id="logo" href="http://swagger.io">swagger</a>
</form> <form id='api_selector'>
</div> <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
</div> <div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
<div class='input'><a id="explore" href="#">Explore</a></div>
<div id="message-bar" class="swagger-ui-wrap">&nbsp;</div> </form>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div> </div>
</body> </div>
</html>
<div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>
...@@ -4,6 +4,7 @@ var popupDialog; ...@@ -4,6 +4,7 @@ var popupDialog;
var clientId; var clientId;
var realm; var realm;
var oauth2KeyName; var oauth2KeyName;
var redirect_uri;
function handleLogin() { function handleLogin() {
var scopes = []; var scopes = [];
...@@ -96,18 +97,19 @@ function handleLogin() { ...@@ -96,18 +97,19 @@ function handleLogin() {
var authSchemes = window.swaggerUi.api.authSchemes; var authSchemes = window.swaggerUi.api.authSchemes;
var host = window.location; var host = window.location;
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/")); var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
var redirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html'; var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl;
var url = null; var url = null;
for (var key in authSchemes) { for (var key in authSchemes) {
if (authSchemes.hasOwnProperty(key)) { if (authSchemes.hasOwnProperty(key)) {
var flow = authSchemes[key].flow; var flow = authSchemes[key].flow;
if(authSchemes[key].type === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) { if(authSchemes[key].type === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) {
var dets = authSchemes[key]; var dets = authSchemes[key];
url = dets.authorizationUrl + '?response_type=' + (flow === 'implicit' ? 'token' : 'code'); url = dets.authorizationUrl + '?response_type=' + (flow === 'implicit' ? 'token' : 'code');
window.swaggerUi.tokenName = dets.tokenName || 'access_token'; window.swaggerUi.tokenName = dets.tokenName || 'access_token';
window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null); window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null);
} }
else if(authSchemes[key].grantTypes) { else if(authSchemes[key].grantTypes) {
// 1.2 support // 1.2 support
...@@ -134,17 +136,23 @@ function handleLogin() { ...@@ -134,17 +136,23 @@ function handleLogin() {
for(k =0; k < o.length; k++) { for(k =0; k < o.length; k++) {
var scope = $(o[k]).attr('scope'); var scope = $(o[k]).attr('scope');
if (scopes.indexOf(scope) === -1) if (scopes.indexOf(scope) === -1)
scopes.push(scope); scopes.push(scope);
} }
// Implicit auth recommends a state parameter.
var state = Math.random ();
window.enabledScopes=scopes; window.enabledScopes=scopes;
redirect_uri = redirectUrl;
url += '&redirect_uri=' + encodeURIComponent(redirectUrl); url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
url += '&realm=' + encodeURIComponent(realm); url += '&realm=' + encodeURIComponent(realm);
url += '&client_id=' + encodeURIComponent(clientId); url += '&client_id=' + encodeURIComponent(clientId);
url += '&scope=' + encodeURIComponent(scopes); url += '&scope=' + encodeURIComponent(scopes.join(' '));
url += '&state=' + encodeURIComponent(state);
window.open(url); window.open(url);
}); });
...@@ -195,29 +203,30 @@ function initOAuth(opts) { ...@@ -195,29 +203,30 @@ function initOAuth(opts) {
}); });
} }
function processOAuthCode(data) { window.processOAuthCode = function processOAuthCode(data) {
var params = { var params = {
'client_id': clientId, 'client_id': clientId,
'code': data.code, 'code': data.code,
'grant_type': 'authorization_code' 'grant_type': 'authorization_code',
'redirect_uri': redirect_uri
} }
$.ajax( $.ajax(
{ {
url : window.swaggerUi.tokenUrl, url : window.swaggerUi.tokenUrl,
type: "POST", type: "POST",
data: params, data: params,
success:function(data, textStatus, jqXHR) success:function(data, textStatus, jqXHR)
{ {
onOAuthComplete(data); onOAuthComplete(data);
}, },
error: function(jqXHR, textStatus, errorThrown) error: function(jqXHR, textStatus, errorThrown)
{ {
onOAuthComplete(""); onOAuthComplete("");
} }
}); });
} }
function onOAuthComplete(token) { window.onOAuthComplete = function onOAuthComplete(token) {
if(token) { if(token) {
if(token.error) { if(token.error) {
var checkbox = $('input[type=checkbox],.secured') var checkbox = $('input[type=checkbox],.secured')
...@@ -264,12 +273,12 @@ function onOAuthComplete(token) { ...@@ -264,12 +273,12 @@ function onOAuthComplete(token) {
// all scopes are satisfied // all scopes are satisfied
$(o).find('.api-ic').addClass('ic-info'); $(o).find('.api-ic').addClass('ic-info');
$(o).find('.api-ic').removeClass('ic-warning'); $(o).find('.api-ic').removeClass('ic-warning');
$(o).find('.api-ic').removeClass('ic-error'); $(o).find('.api-ic').removeClass('ic-error');
} }
} }
}); });
window.authorizations.add(oauth2KeyName, new ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header')); window.swaggerUi.api.clientAuthorizations.add(oauth2KeyName, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
} }
} }
} }
} }
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment