Update swagger to 2.0.24

This commit is contained in:
Laurent Destailleur 2017-05-24 15:12:45 +02:00
parent 6d4c5e4b4a
commit f011197e00
10 changed files with 552 additions and 523 deletions

137
COPYRIGHT
View File

@ -21,13 +21,13 @@ GeoIP 1.4 LGPL-2.1+ Yes
Mobiledetect 2.8.17 MIT License Yes Detect mobile devices browsers Mobiledetect 2.8.17 MIT License Yes Detect mobile devices browsers
NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency
odtPHP 1.0.1 GPL-2+ b Yes Library to build/edit ODT files odtPHP 1.0.1 GPL-2+ Yes Library to build/edit ODT files
ParseDown 1.6 MIT License Yes Markdown parser ParseDown 1.6 MIT License Yes Markdown parser
PHPExcel 1.8.1 LGPL-2.1+ Yes Read/Write XLS files, read ODS files PHPExcel 1.8.1 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
php-iban 1.4.7 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP php-iban 1.4.7 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP
PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service
PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests
Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer)
TCPDF 6.2.12 LGPL-3+ Yes PDF generation TCPDF 6.2.12 LGPL-3+ Yes PDF generation
TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement
Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP
@ -52,138 +52,13 @@ jQuery Timepicker 1.1.0 GPL and MIT License Yes
jQuery Tiptip 1.3 GPL and MIT License Yes JS library for tooltips jQuery Tiptip 1.3 GPL and MIT License Yes JS library for tooltips
jsGanttImproved 1.7.5.2 BSD License Yes JS library (to build Gantt reports) jsGanttImproved 1.7.5.2 BSD License Yes JS library (to build Gantt reports)
JsTimezoneDetect 1.0.6 MIT License Yes JS library to detect user timezone JsTimezoneDetect 1.0.6 MIT License Yes JS library to detect user timezone
SwaggerUI 2.0.24 GPL-2+ Yes JS library to offer the REST API explorer
For licenses compatibility informations: For licenses compatibility informations:
http://www.gnu.org/licenses/licenses.en.html http://www.gnu.org/licenses/licenses.en.html
Copyright Copyright / Authors
--------- -------------------
Copyright (C) 2016
Copyright (C) 2015
- Laurent Destailleur <eldy@users.sourceforge.net>
- Marcos García <marcosgdf@gmail.com>
- Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
- Frederic France <frederic.france@free.fr>
- Regis Houssin <regis.houssin@capnetworks.com>
Copyright (C) 2014
- Laurent Destailleur <eldy@users.sourceforge.net>
- Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
- Jean-François Ferry <jfefe@aternatik.fr>
- Marcos García <marcosgdf@gmail.com>
- Philippe Grand <philippe.grand@atoo-net.com>
- Florian Henry <florian.henry@open-concept.pro>
- Regis Houssin <regis.houssin@capnetworks.com>
- Maxime Kohlhaas <mko@atm-consulting.fr>
- Juanjo Menent <jmenent@2byte.es>
- Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
- Frederic France <frederic.france@free.fr>
Copyright (C) 2013
- Christophe Battarel <christophe.battarel@altairis.fr>
- Laurent Destailleur <eldy@users.sourceforge.net>
- Jean-François Ferry <jfefe@aternatik.fr>
- Marcos García <marcosgdf@gmail.com>
- Philippe Grand <philippe.grand@atoo-net.com>
- Florian Henry <florian.henry@open-concept.pro>
- Regis Houssin <regis.houssin@capnetworks.com>
- Maxime Kohlhaas <mko@atm-consulting.fr>
- Juanjo Menent <jmenent@2byte.es>
- Adolfo Segura <adolfo.segura@gmail.com>
- Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
Copyright (C) 2012
- Christophe Battarel <christophe.battarel@altairis.fr>
- Laurent Destailleur <eldy@users.sourceforge.net>
- Jean-François Ferry <jfefe@aternatik.fr>
- Marcos García <marcosgdf@gmail.com>
- Philippe Grand <philippe.grand@atoo-net.com>
- Jean Heimburger <jean@tiaris.info>
- Florian Henry <florian.henry@open-concept.pro>
- Regis Houssin <regis.houssin@capnetworks.com>
- Maxime Kohlhaas <mko@atm-consulting.fr>
- Juanjo Menent <jmenent@2byte.es>
- Nicolas Péré <nicolas@amarok2.net>
- Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
Copyright (C) 2011
- Laurent Destailleur <eldy@users.sourceforge.net>
- Regis Houssin <regis.houssin@capnetworks.com>
- Juanjo Menent <jmenent@2byte.es>
- Philippe Grand <philippe.grand@atoo-net.com>
- Jean Heimburger <jean@tiaris.info>
Copyright (C) 2010
- Laurent Destailleur <eldy@users.sourceforge.net>
- Regis Houssin <regis.houssin@capnetworks.com>
- Juanjo Menent <jmenent@2byte.es>
- r2gnl
- meos
Copyright (C) 2009
- Laurent Destailleur <eldy@users.sourceforge.net>
- Regis Houssin <regis.houssin@capnetworks.com>
- Juanjo Menent <jmenent@2byte.es>
Copyright (C) 2008
- Laurent Destailleur <eldy@users.sourceforge.net>
- Regis Houssin <regis.houssin@capnetworks.com>
- Rodolphe Quiedeville <rodolphe@quiedeville.org>
- Jeremie Ollivier <jeremie.o@laposte.net>
Copyright (C) 2007
- Rodolphe Quiedeville <rodolphe@quiedeville.org>
- Laurent Destailleur <eldy@users.sourceforge.net>
- Regis Houssin <regis.houssin@capnetworks.com>
- Auguria SARL <info@auguria.org>
- Jean Heimburger <jean@tiaris.info>
- Jeremie Ollivier <jeremie.o@laposte.net>
Copyright (C) 2006
- Auguria SARL <info@auguria.org>
- Marc Barilley/Ocebo <marc@ocebo.com>
- Laurent Destailleur <eldy@users.sourceforge.net>
- Rodolphe Quiedeville <rodolphe@quiedeville.org>
- Regis Houssin <regis.houssin@capnetworks.com>
- Andre Cianfarani <acianfa@free.fr>
- Yannick Warnier <ywarnier@beeznest.org>
- Jean Heimburger <jean@tiaris.info>
Copyright (C) 2005
- Brice Davoleau <brice.davoleau@gmail.com>
- Laurent Destailleur <eldy@users.sourceforge.net>
- Benoit Mortier <benoit.mortier@opensides.be>
- Rodolphe Quiedeville <rodolphe@quiedeville.org>
- Eric Seigne <erics@rycks.com>
- Matthieu Valleton <mv@seeschloss.org>
- Regis Houssin <regis.houssin@capnetworks.com>
Copyright (C) 2004
- Laurent Destailleur <eldy@users.sourceforge.net>
- Rodolphe Quiedeville <rodolphe@quiedeville.org>
- Eric Seigne <erics@rycks.com>
- Benoit Mortier <benoit.mortier@opensides.be>
- Christophe Combelles <ccomb@free.fr>
- Sebastien Di Cintio <sdicintio@ressource-toi.org>
Copyright (C) 2003
- Jean-Louis Bergamo <jlb@j1b.org>
- Xavier Dutoit <doli@sydesy.com>
- Rodolphe Quiedeville <rodolphe@quiedeville.org>
- Emmanuel Raviart <eraviart@entrouvert.com>
- Eric Seigne <erics@rycks.com>
Copyright (C) 2002
- Jean-Louis Bergamo <jlb@j1b.org>
- Rodolphe Quiedeville <rodolphe@quiedeville.org>
Copyright (C) 2001
- Rodolphe Quiedeville <rodolphe@quiedeville.org>
See page https://github.com/Dolibarr/dolibarr/graphs/contributors

View File

@ -350,7 +350,7 @@
font-size: .85em; font-size: .85em;
line-height: 1.2em; line-height: 1.2em;
overflow: auto; overflow: auto;
max-height: 400px; max-height: 200px;
cursor: pointer; cursor: pointer;
} }
.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav { .swagger-section .swagger-ui-wrap .model-signature ul.signature-nav {
@ -743,17 +743,20 @@
display: inline-block; display: inline-block;
font-size: 0.9em; font-size: 0.9em;
} }
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header img {
display: block;
clear: none;
float: right;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit { .swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit {
display: block; display: block;
clear: none; clear: none;
float: left; float: left;
padding: 6px 8px; padding: 6px 8px;
} }
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header span.response_throbber {
background-image: url('../images/throbber.gif');
width: 128px;
height: 16px;
display: block;
clear: none;
float: right;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error { .swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error {
outline: 2px solid black; outline: 2px solid black;
outline-color: #cc0000; outline-color: #cc0000;
@ -1158,7 +1161,7 @@
cursor: pointer; cursor: pointer;
} }
.swagger-section #header { .swagger-section #header {
background-color: #646257; background-color: #89bf04;
padding: 14px; padding: 14px;
} }
.swagger-section #header a#logo { .swagger-section #header a#logo {
@ -1193,7 +1196,7 @@
padding: 6px 8px; padding: 6px 8px;
font-size: 0.9em; font-size: 0.9em;
color: white; color: white;
background-color: #000000; background-color: #547f00;
-moz-border-radius: 4px; -moz-border-radius: 4px;
-webkit-border-radius: 4px; -webkit-border-radius: 4px;
-o-border-radius: 4px; -o-border-radius: 4px;
@ -1202,35 +1205,13 @@
border-radius: 4px; border-radius: 4px;
} }
.swagger-section #header form#api_selector .input a#explore:hover { .swagger-section #header form#api_selector .input a#explore:hover {
background-color: #a41e22; background-color: #547f00;
} }
.swagger-section #header form#api_selector .input input { .swagger-section #header form#api_selector .input input {
font-size: 0.9em; font-size: 0.9em;
padding: 3px; padding: 3px;
margin: 0; margin: 0;
} }
.swagger-section #footer-nav {
margin-top: 50px;
color: #bbb;
float: left;
list-style: none;
font-size: 0.8em;
}
.swagger-section #footer-nav li {
display: block;
float: left;
}
.swagger-section #footer-nav a {
margin-right: 4px;
text-decoration: none;
font-weight: none;
padding: 4px 2px;
font-size: 0.9em;
color: #999;
}
.swagger-section #footer-nav a:hover {
color: #555;
}
.swagger-section #content_message { .swagger-section #content_message {
margin: 10px 15px; margin: 10px 15px;
font-style: italic; font-style: italic;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 980 B

View File

@ -2,8 +2,7 @@
<html> <html>
<head> <head>
<title>Api Explorer</title> <title>Api Explorer</title>
<!-- DOL_CHANGE LDR Remove external links <link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/> <!-- DOL_CHANGE LDR Remove external links <link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>-->
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">-->
<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'/>
<link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/> <link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
@ -27,10 +26,11 @@
$(function () { $(function () {
window.swaggerUi = new SwaggerUi({ window.swaggerUi = new SwaggerUi({
url: "resources.json", url: "resources.json",
validatorUrl: null,
dom_id: "swagger-ui-container", dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'patch', 'delete'], supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){ onComplete: function(swaggerApi, swaggerUi){
log("Loaded Api Explorer"); log("Loaded API Explorer");
if(typeof initOAuth == "function") { if(typeof initOAuth == "function") {
/* /*
@ -45,15 +45,19 @@
hljs.highlightBlock(e) hljs.highlightBlock(e)
}); });
}, },
defaultModelRendering: 'model',
onFailure: function(data) { onFailure: function(data) {
log("Unable to Load Api Explorer"); log("Unable to Load API Explorer");
}, },
docExpansion: "none" docExpansion: "none",
/*showRequestHeaders: true,
jsonEditor: true */
/*, sorter : "alpha"*/
}); });
$('#input_apiKey').change(function() { $('#input_apiKey').change(function() {
var key = $('#input_apiKey')[0].value; var key = $('#input_apiKey')[0].value;
log("key: " + key);
if(key && key.trim() != "") { if(key && key.trim() != "") {
/* DOL_CHANGE LDR We set DOLAPIKEY into header */ /* DOL_CHANGE LDR We set DOLAPIKEY into header */
log("added key " + key); log("added key " + key);
@ -67,11 +71,15 @@
console.log("header DOLAPIKEY added with value "+key); console.log("header DOLAPIKEY added with value "+key);
} }
}) })
window.swaggerUi.load(); window.swaggerUi.load();
}); });
</script> </script>
<style>
.info_title, .info_description, .info_contact, .info_license {
display: none;
}
</style>
</head> </head>
<body class="swagger-section"> <body class="swagger-section">
@ -79,6 +87,14 @@
<div class="swagger-ui-wrap"> <div class="swagger-ui-wrap">
<a id="logo" href="#">API Explorer</a> <a id="logo" href="#">API Explorer</a>
<form id='api_selector'> <form id='api_selector'>
<!-- DOL_CHANGE LDR
<div class='input icon-btn'>
<img id="show-pet-store-icon" src="images/pet_store_api.png" title="Show Swagger Petstore Example Apis">
</div>
<div class='input icon-btn'>
<img id="show-wordnik-dev-icon" src="images/wordnik_api.png" title="Show Wordnik Developer Apis">
</div>
-->
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="hidden" value="resources.json"/></div> <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="hidden" value="resources.json"/></div>
<div class='input'><input placeholder="DOLAPIKEY" id="input_apiKey" name="apiKey" type="text"/></div> <div class='input'><input placeholder="DOLAPIKEY" id="input_apiKey" name="apiKey" type="text"/></div>
<div class='input'><a id="explore" href="#">Explore</a></div> <div class='input'><a id="explore" href="#">Explore</a></div>

View File

@ -48,7 +48,7 @@ function handleLogin() {
str += '</label></li>'; str += '</label></li>';
popup.append(str); popup.append(str);
} }
}
var $win = $(window), var $win = $(window),
dw = $win.width(), dw = $win.width(),
@ -73,15 +73,14 @@ function handleLogin() {
popupDialog.hide(); popupDialog.hide();
var authSchemes = window.swaggerUi.api.authSchemes; var authSchemes = window.swaggerUi.api.authSchemes;
var location = window.location; var host = window.location;
var locationUrl = location.protocol + '//' + location.host + location.pathname; var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
var redirectUrl = locationUrl.replace("index.html","").concat("/o2c.html").replace("//o2c.html","/o2c.html"); var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html";
var url = null; var url = null;
var p = window.swaggerUi.api.authSchemes; for (var key in authSchemes) {
for (var key in p) { if (authSchemes.hasOwnProperty(key)) {
if (p.hasOwnProperty(key)) { var o = authSchemes[key].grantTypes;
var o = p[key].grantTypes;
for(var t in o) { for(var t in o) {
if(o.hasOwnProperty(t) && t === 'implicit') { if(o.hasOwnProperty(t) && t === 'implicit') {
var dets = o[t]; var dets = o[t];
@ -91,29 +90,23 @@ function handleLogin() {
} }
} }
} }
var scopes = []; var scopes = []
var scopeForUrl='';
var o = $('.api-popup-scopes').find('input:checked'); var o = $('.api-popup-scopes').find('input:checked');
for(var k =0; k < o.length; k++) { for(k =0; k < o.length; k++) {
scopes.push($(o[k]).attr("scope")); scopes.push($(o[k]).attr("scope"));
if(k > 0){
scopeForUrl+=' ';
}
scopeForUrl+=$(o[k]).attr("scope");
} }
window.enabledScopes=scopes; window.enabledScopes=scopes;
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(scopeForUrl); url += '&scope=' + encodeURIComponent(scopes);
window.open(url); window.open(url);
}); });
}
popupMask.show(); popupMask.show();
popupDialog.show(); popupDialog.show();
return; return;
@ -211,7 +204,7 @@ function onOAuthComplete(token) {
} }
}); });
window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header")); window.authorizations.add("oauth2", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
} }
} }
} }

View File

@ -1,5 +1,5 @@
// swagger.js // swagger.js
// version 2.0.30 // version 2.0.39
var __bind = function(fn, me){ var __bind = function(fn, me){
return function(){ return function(){
@ -11,10 +11,20 @@ log = function(){
log.history = log.history || []; log.history = log.history || [];
log.history.push(arguments); log.history.push(arguments);
if(this.console){ if(this.console){
console.log( Array.prototype.slice.call(arguments) ); console.log( Array.prototype.slice.call(arguments)[0] );
} }
}; };
// if you want to apply conditional formatting of parameter values
parameterMacro = function(value) {
return value;
}
// if you want to apply conditional formatting of model property values
modelPropertyMacro = function(value) {
return value;
}
if (!Array.prototype.indexOf) { if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) { Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) { for (var i = (start || 0), j = this.length; i < j; i++) {
@ -79,14 +89,16 @@ Object.keys = Object.keys || (function () {
}; };
})(); })();
var SwaggerApi = function(url, options) { var SwaggerApi = function(url, options) {
this.isBuilt = false;
this.url = null; this.url = null;
this.debug = false; this.debug = false;
this.basePath = null; this.basePath = null;
this.authorizations = null; this.authorizations = null;
this.authorizationScheme = null; this.authorizationScheme = null;
this.info = null; this.info = null;
this.useJQuery = false;
this.modelsArray = [];
options = (options||{}); options = (options||{});
if (url) if (url)
@ -103,13 +115,20 @@ var SwaggerApi = function(url, options) {
if (options.success != null) if (options.success != null)
this.success = options.success; this.success = options.success;
if (typeof options.useJQuery === 'boolean')
this.useJQuery = options.useJQuery;
this.failure = options.failure != null ? options.failure : function() {}; this.failure = options.failure != null ? options.failure : function() {};
this.progress = options.progress != null ? options.progress : function() {}; this.progress = options.progress != null ? options.progress : function() {};
if (options.success != null) if (options.success != null) {
this.build(); this.build();
this.isBuilt = true;
}
} }
SwaggerApi.prototype.build = function() { SwaggerApi.prototype.build = function() {
if(this.isBuilt)
return this;
var _this = this; var _this = this;
this.progress('fetching resource list: ' + this.url); this.progress('fetching resource list: ' + this.url);
var obj = { var obj = {
@ -117,7 +136,7 @@ SwaggerApi.prototype.build = function() {
url: this.url, url: this.url,
method: "get", method: "get",
headers: { headers: {
accept: "application/json" accept: "application/json,application/json;charset=\"utf-8\",*/*"
}, },
on: { on: {
error: function(response) { error: function(response) {
@ -154,6 +173,7 @@ SwaggerApi.prototype.buildFromSpec = function(response) {
} }
this.apis = {}; this.apis = {};
this.apisArray = []; this.apisArray = [];
this.consumes = response.consumes;
this.produces = response.produces; this.produces = response.produces;
this.authSchemes = response.authorizations; this.authSchemes = response.authorizations;
if (response.info != null) { if (response.info != null) {
@ -171,13 +191,13 @@ SwaggerApi.prototype.buildFromSpec = function(response) {
} }
} }
} }
if (response.basePath) { if (response.basePath)
this.basePath = response.basePath; this.basePath = response.basePath;
} else if (this.url.indexOf('?') > 0) { else if (this.url.indexOf('?') > 0)
this.basePath = this.url.substring(0, this.url.lastIndexOf('?')); this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
} else { else
this.basePath = this.url; this.basePath = this.url;
}
if (isApi) { if (isApi) {
var newName = response.resourcePath.replace(/\//g, ''); var newName = response.resourcePath.replace(/\//g, '');
this.resourcePath = response.resourcePath; this.resourcePath = response.resourcePath;
@ -272,7 +292,6 @@ SwaggerApi.prototype.fail = function(message) {
SwaggerApi.prototype.setConsolidatedModels = function() { SwaggerApi.prototype.setConsolidatedModels = function() {
var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results; var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
this.modelsArray = [];
this.models = {}; this.models = {};
_ref = this.apis; _ref = this.apis;
for (resource_name in _ref) { for (resource_name in _ref) {
@ -317,8 +336,8 @@ var SwaggerResource = function(resourceObj, api) {
var _this = this; var _this = this;
this.api = api; this.api = api;
this.api = this.api; this.api = this.api;
produces = []; consumes = (this.consumes | []);
consumes = []; produces = (this.produces | []);
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path; this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
this.description = resourceObj.description; this.description = resourceObj.description;
@ -349,7 +368,7 @@ var SwaggerResource = function(resourceObj, api) {
method: "get", method: "get",
useJQuery: this.useJQuery, useJQuery: this.useJQuery,
headers: { headers: {
accept: "application/json" accept: "application/json,application/json;charset=\"utf-8\",*/*"
}, },
on: { on: {
response: function(resp) { response: function(resp) {
@ -368,22 +387,28 @@ var SwaggerResource = function(resourceObj, api) {
} }
} }
SwaggerResource.prototype.getAbsoluteBasePath = function(relativeBasePath) { SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {
var parts, pos, url; var pos, url;
url = this.api.basePath; url = this.api.basePath;
pos = url.lastIndexOf(relativeBasePath); pos = url.lastIndexOf(relativeBasePath);
if (pos === -1) { var parts = url.split("/");
parts = url.split("/"); var rootUrl = parts[0] + "//" + parts[2];
url = parts[0] + "//" + parts[2];
if (relativeBasePath.indexOf("/") === 0) { if(relativeBasePath.indexOf("http") === 0)
return url + relativeBasePath; return relativeBasePath;
} else { if(relativeBasePath === "/")
return url + "/" + relativeBasePath; return rootUrl;
if(relativeBasePath.substring(0, 1) == "/") {
// use root + relative
return rootUrl + relativeBasePath;
} }
} else if (relativeBasePath === "/") { else {
return url.substring(0, pos); var pos = this.basePath.lastIndexOf("/");
} else { var base = this.basePath.substring(0, pos);
return url.substring(0, pos) + relativeBasePath; if(base.substring(base.length - 1) == "/")
return base + relativeBasePath;
else
return base + "/" + relativeBasePath;
} }
}; };
@ -478,8 +503,7 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes,
SwaggerResource.prototype.sanitize = function(nickname) { SwaggerResource.prototype.sanitize = function(nickname) {
var op; var op;
op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|./?,\\'""-]/g, '_'); op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_');
//'
op = op.replace(/((_){2,})/g, '_'); op = op.replace(/((_){2,})/g, '_');
op = op.replace(/^(_)*/g, ''); op = op.replace(/^(_)*/g, '');
op = op.replace(/([_])*$/g, ''); op = op.replace(/([_])*$/g, '');
@ -584,6 +608,7 @@ var SwaggerModelProperty = function(name, obj) {
this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set'); this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
this.descr = obj.description; this.descr = obj.description;
this.required = obj.required; this.required = obj.required;
this.defaultValue = modelPropertyMacro(obj.defaultValue);
if (obj.items != null) { if (obj.items != null) {
if (obj.items.type != null) { if (obj.items.type != null) {
this.refDataType = obj.items.type; this.refDataType = obj.items.type;
@ -629,7 +654,9 @@ SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
SwaggerModelProperty.prototype.toSampleValue = function(value) { SwaggerModelProperty.prototype.toSampleValue = function(value) {
var result; var result;
if (value === "integer") { if ((typeof this.defaultValue !== 'undefined') && this.defaultValue !== null) {
result = this.defaultValue;
} else if (value === "integer") {
result = 0; result = 0;
} else if (value === "boolean") { } else if (value === "boolean") {
result = false; result = false;
@ -759,6 +786,7 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not
} }
} }
} }
param.defaultValue = parameterMacro(param.defaultValue);
} }
this.resource[this.nickname] = function(args, callback, error) { this.resource[this.nickname] = function(args, callback, error) {
return _this["do"](args, callback, error); return _this["do"](args, callback, error);
@ -1073,7 +1101,7 @@ SwaggerOperation.prototype.formatXml = function(xml) {
var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) { var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) {
var _this = this; var _this = this;
var errors = []; var errors = [];
this.useJQuery = (typeof operation.useJQuery !== 'undefined' ? operation.useJQuery : null); this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null);
this.type = (type||errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options).")); this.type = (type||errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options)."));
this.url = (url||errors.push("SwaggerRequest url is required.")); this.url = (url||errors.push("SwaggerRequest url is required."));
this.params = params; this.params = params;
@ -1090,71 +1118,22 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
this.type = this.type.toUpperCase(); this.type = this.type.toUpperCase();
var myHeaders = {}; // set request, response content type headers
var headers = this.setHeaders(params, this.operation);
var body = params.body; var body = params.body;
var parent = params["parent"];
var requestContentType = "application/json";
var formParams = []; // encode the body for form submits
var fileParams = []; if (headers["Content-Type"]) {
var params = this.operation.parameters;
for(var i = 0; i < params.length; i++) {
var param = params[i];
if(param.paramType === "form")
formParams.push(param);
else if(param.paramType === "file")
fileParams.push(param);
}
if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) {
if (this.opts.requestContentType) {
requestContentType = this.opts.requestContentType;
}
} else {
// if any form params, content type must be set
if(formParams.length > 0) {
if(fileParams.length > 0)
requestContentType = "multipart/form-data";
else
requestContentType = "application/x-www-form-urlencoded";
}
else if (this.type != "DELETE")
requestContentType = null;
}
if (requestContentType && this.operation.consumes) {
if (this.operation.consumes[requestContentType] === 'undefined') {
log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes));
if (this.requestContentType === null) {
requestContentType = this.operation.consumes[0];
}
}
}
var responseContentType = null;
if (this.opts.responseContentType) {
responseContentType = this.opts.responseContentType;
} else {
responseContentType = "application/json";
}
if (responseContentType && this.operation.produces) {
if (this.operation.produces[responseContentType] === 'undefined') {
log("server can't produce " + responseContentType);
}
}
if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
var fields = {};
var possibleParams = {};
var values = {}; var values = {};
var key; var i;
for(key in formParams){ var operationParams = this.operation.parameters;
var param = formParams[key]; for(i = 0; i < operationParams.length; i++) {
var param = operationParams[i];
if(param.paramType === "form")
values[param.name] = param; values[param.name] = param;
} }
if(headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
var encoded = ""; var encoded = "";
var key; var key;
for(key in values) { for(key in values) {
@ -1167,19 +1146,31 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
} }
body = encoded; body = encoded;
} }
var name; else if (headers["Content-Type"].indexOf("multipart/form-data") === 0) {
for (name in this.headers) // encode the body for form submits
myHeaders[name] = this.headers[name]; var data = "";
if ((requestContentType && body !== "") || (requestContentType === "application/x-www-form-urlencoded")) var boundary = "----SwaggerFormBoundary" + Date.now();
myHeaders["Content-Type"] = requestContentType; var key;
if (responseContentType) for(key in values) {
myHeaders["Accept"] = responseContentType; value = this.params[key];
if(typeof value !== 'undefined') {
data += '--' + boundary + '\n';
data += 'Content-Disposition: form-data; name="' + key + '"';
data += '\n\n';
data += value + "\n";
}
}
data += "--" + boundary + "--\n";
headers["Content-Type"] = "multipart/form-data; boundary=" + boundary;
body = data;
}
}
if (!((this.headers != null) && (this.headers.mock != null))) { if (!((this.headers != null) && (this.headers.mock != null))) {
obj = { obj = {
url: this.url, url: this.url,
method: this.type, method: this.type,
headers: myHeaders, headers: headers,
body: body, body: body,
useJQuery: this.useJQuery, useJQuery: this.useJQuery,
on: { on: {
@ -1216,6 +1207,77 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
} }
}; };
SwaggerRequest.prototype.setHeaders = function(params, operation) {
// default type
var accepts = "application/json";
var consumes = "application/json";
var allDefinedParams = this.operation.parameters;
var definedFormParams = [];
var definedFileParams = [];
var body = params.body;
var headers = {};
// get params from the operation and set them in definedFileParams, definedFormParams, headers
var i;
for(i = 0; i < allDefinedParams.length; i++) {
var param = allDefinedParams[i];
if(param.paramType === "form")
definedFormParams.push(param);
else if(param.paramType === "file")
definedFileParams.push(param);
else if(param.paramType === "header" && this.params.headers) {
var key = param.name;
var headerValue = this.params.headers[param.name];
if(typeof this.params.headers[param.name] !== 'undefined')
headers[key] = headerValue;
}
}
// if there's a body, need to set the accepts header via requestContentType
if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH" || this.type === "DELETE")) {
if (this.opts.requestContentType)
consumes = this.opts.requestContentType;
} else {
// if any form params, content type must be set
if(definedFormParams.length > 0) {
if(definedFileParams.length > 0)
consumes = "multipart/form-data";
else
consumes = "application/x-www-form-urlencoded";
}
else if (this.type === "DELETE")
body = "{}";
else if (this.type != "DELETE")
accepts = null;
}
if (consumes && this.operation.consumes) {
if (this.operation.consumes.indexOf(consumes) === -1) {
log("server doesn't consume " + consumes + ", try " + JSON.stringify(this.operation.consumes));
consumes = this.operation.consumes[0];
}
}
if (this.opts.responseContentType) {
accepts = this.opts.responseContentType;
} else {
accepts = "application/json";
}
if (accepts && this.operation.produces) {
if (this.operation.produces.indexOf(accepts) === -1) {
log("server can't produce " + accepts);
accepts = this.operation.produces[0];
}
}
if ((consumes && body !== "") || (consumes === "application/x-www-form-urlencoded"))
headers["Content-Type"] = consumes;
if (accepts)
headers["Accept"] = accepts;
return headers;
}
SwaggerRequest.prototype.asCurl = function() { SwaggerRequest.prototype.asCurl = function() {
var results = []; var results = [];
if(this.headers) { if(this.headers) {
@ -1259,9 +1321,16 @@ SwaggerHttp.prototype.isIE8 = function() {
}; };
/* /*
* JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic * JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.
* NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.
* Since we are using closures here we need to alias it for internal use.
*/ */
var JQueryHttpClient = function(options) {} var JQueryHttpClient = function(options) {
"use strict";
if(!jQuery){
var jQuery = window.jQuery;
}
}
JQueryHttpClient.prototype.execute = function(obj) { JQueryHttpClient.prototype.execute = function(obj) {
var cb = obj.on; var cb = obj.on;
@ -1335,8 +1404,8 @@ JQueryHttpClient.prototype.execute = function(obj) {
return cb.response(out); return cb.response(out);
}; };
$.support.cors = true; jQuery.support.cors = true;
return $.ajax(obj); return jQuery.ajax(obj);
} }
/* /*
@ -1411,11 +1480,36 @@ ShredHttpClient.prototype.execute = function(obj) {
return out; return out;
}; };
// Transform an error into a usable response-like object
var transformError = function(error) {
var out = {
// Default to a status of 0 - The client will treat this as a generic permissions sort of error
status: 0,
data: error.message || error
};
if(error.code) {
out.obj = error;
if(error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED' ) {
// We can tell the client that this should be treated as a missing resource and not as a permissions thing
out.status = 404;
}
}
return out;
};
res = { res = {
error: function(response) { error: function(response) {
if (obj) if (obj)
return cb.error(transform(response)); return cb.error(transform(response));
}, },
// Catch the Shred error raised when the request errors as it is made (i.e. No Response is coming)
request_error: function(err) {
if(obj)
return cb.error(transformError(err));
},
redirect: function(response) { redirect: function(response) {
if (obj) if (obj)
return cb.redirect(transform(response)); return cb.redirect(transform(response));
@ -1452,26 +1546,42 @@ SwaggerAuthorizations.prototype.remove = function(name) {
}; };
SwaggerAuthorizations.prototype.apply = function(obj, authorizations) { SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
status = null; var status = null;
var key; var key;
// if the "authorizations" key is undefined, or has an empty array, add all keys
if(typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
for (key in this.authz) { for (key in this.authz) {
value = this.authz[key]; value = this.authz[key];
result = value.apply(obj, authorizations); result = value.apply(obj, authorizations);
if (result === false)
status = false;
if (result === true) if (result === true)
status = true; status = true;
} }
}
else {
for(name in authorizations) {
for (key in this.authz) {
if(key == name) {
value = this.authz[key];
result = value.apply(obj, authorizations);
if (result === true)
status = true;
}
}
}
}
return status; return status;
}; };
/** /**
* ApiKeyAuthorization allows a query param or header to be injected * ApiKeyAuthorization allows a query param or header to be injected
*/ */
var ApiKeyAuthorization = function(name, value, type) { var ApiKeyAuthorization = function(name, value, type, delimiter) {
this.name = name; this.name = name;
this.value = value; this.value = value;
this.type = type; this.type = type;
this.delimiter = delimiter;
}; };
ApiKeyAuthorization.prototype.apply = function(obj, authorizations) { ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
@ -1482,6 +1592,11 @@ ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
obj.url = obj.url + "?" + this.name + "=" + this.value; obj.url = obj.url + "?" + this.name + "=" + this.value;
return true; return true;
} else if (this.type === "header") { } else if (this.type === "header") {
if(typeof obj.headers[this.name] !== 'undefined') {
if(typeof this.delimiter !== 'undefined')
obj.headers[this.name] = obj.headers[this.name] + this.delimiter + this.value;
}
else
obj.headers[this.name] = this.value; obj.headers[this.name] = this.value;
return true; return true;
} }

View File

@ -1,5 +1,5 @@
// swagger-ui.js // swagger-ui.js
// version 2.0.17 // version 2.0.23
$(function() { $(function() {
// Helper function for vertically aligning DOM elements // Helper function for vertically aligning DOM elements
@ -68,7 +68,7 @@ log = function(){
log.history = log.history || []; log.history = log.history || [];
log.history.push(arguments); log.history.push(arguments);
if(this.console){ if(this.console){
console.log( Array.prototype.slice.call(arguments) ); console.log( Array.prototype.slice.call(arguments)[0] );
} }
}; };
@ -240,7 +240,12 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
function program1(depth0,data) { function program1(depth0,data) {
var buffer = "", stack1, stack2; var buffer = "", stack1, stack2;
buffer += "\n "; buffer += "\n <div class=\"info_title\">"
+ escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</div>\n <div class=\"info_description\">";
stack2 = ((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.description)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1);
if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += "</div>\n ";
stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.termsOfServiceUrl), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.termsOfServiceUrl), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
if(stack2 || stack2 === 0) { buffer += stack2; } if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += "\n "; buffer += "\n ";
@ -255,52 +260,54 @@ function program1(depth0,data) {
function program2(depth0,data) { function program2(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "<li><a href=\"" buffer += "<div class=\"info_tos\"><a href=\""
+ escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.termsOfServiceUrl)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.termsOfServiceUrl)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "\" title=\"Terms of Service\"><i class=\"fa fa-lg fa-bullhorn\"></i> Terms</a></li>"; + "\">Terms of service</a></div>";
return buffer; return buffer;
} }
function program4(depth0,data) { function program4(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "<li><a href=\"mailto:" buffer += "<div class='info_contact'><a href=\"mailto:"
+ escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "\"><i class=\"fa fa-lg fa-send\"></i> Contact</a></li>"; + "\">Contact the developer</a></div>";
return buffer; return buffer;
} }
function program6(depth0,data) { function program6(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "<li><a href=\"" buffer += "<div class='info_license'><a href='"
+ escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.licenseUrl)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.licenseUrl)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "\" title=\"" + "'>"
+ escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "\"><i class=\"fa fa-lg fa-certificate\"></i> License</a></li>"; + "</a></div>";
return buffer; return buffer;
} }
function program8(depth0,data) { function program8(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += " v"; buffer += "\n , <span style=\"font-variant: small-caps\">api version</span>: ";
if (stack1 = helpers.apiVersion) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.apiVersion) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.apiVersion; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.apiVersion; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1); buffer += escapeExpression(stack1)
+ "\n ";
return buffer; return buffer;
} }
buffer += "<div class='info' id='api_info'>\n</div>\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <ul id=\"footer-nav\">\n "; buffer += "<div class='info' id='api_info'>\n ";
stack1 = helpers['if'].call(depth0, depth0.info, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); stack1 = helpers['if'].call(depth0, depth0.info, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; } if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n <li>\n "; buffer += "\n</div>\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";
if (stack1 = helpers.basePath) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.basePath) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.basePath; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.basePath; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1); buffer += escapeExpression(stack1)
+ "\n ";
stack1 = helpers['if'].call(depth0, depth0.apiVersion, {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data}); stack1 = helpers['if'].call(depth0, depth0.apiVersion, {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; } if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += " Powered by Restler & Swagger\n </li>\n </ul>\n </div>\n</div>\n"; buffer += "]</h4>\n </div>\n</div>\n";
return buffer; return buffer;
}); });
})(); })();
@ -389,7 +396,7 @@ function program18(depth0,data) {
function program20(depth0,data) { function program20(depth0,data) {
return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n "; return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <span class='response_throbber' style='display:none'></span>\n </div>\n ";
} }
buffer += "\n <ul class='operations' >\n <li class='"; buffer += "\n <ul class='operations' >\n <li class='";
@ -555,13 +562,22 @@ function program9(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "\n "; buffer += "\n ";
stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(12, program12, data),fn:self.program(10, program10, data),data:data}); stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(10, program10, data),fn:self.program(2, program2, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; } if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n "; buffer += "\n ";
return buffer; return buffer;
} }
function program10(depth0,data) { function program10(depth0,data) {
var buffer = "", stack1;
buffer += "\n ";
stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(13, program13, data),fn:self.program(11, program11, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
return buffer;
}
function program11(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "\n <input class='parameter' minlength='0' name='"; buffer += "\n <input class='parameter' minlength='0' name='";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
@ -575,7 +591,7 @@ function program10(depth0,data) {
return buffer; return buffer;
} }
function program12(depth0,data) { function program13(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "\n <input class='parameter' minlength='0' name='"; buffer += "\n <input class='parameter' minlength='0' name='";
@ -1057,23 +1073,19 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
function program1(depth0,data) { function program1(depth0,data) {
var buffer = "", stack1;
buffer += " : "; return " : ";
if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if(stack1 || stack1 === 0) { buffer += stack1; }
return buffer;
} }
buffer += "<div class='heading'>\n <h2>\n <a href='#!/"; buffer += "<div class='heading'>\n <h2>\n <a href='#!/";
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "' onclick=\"Docs.toggleEndpointListForResource('"; + "' class=\"toggleEndpointList\" data-id=\"";
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "');\">"; + "\">";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
@ -1083,6 +1095,9 @@ function program1(depth0,data) {
else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if (!helpers.description) { stack1 = blockHelperMissing.call(depth0, stack1, options); } if (!helpers.description) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
if(stack1 || stack1 === 0) { buffer += stack1; } if(stack1 || stack1 === 0) { buffer += stack1; }
if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/"; buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
@ -1091,19 +1106,19 @@ function program1(depth0,data) {
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "'\n onclick=\"Docs.toggleEndpointListForResource('"; + "' class=\"toggleEndpointList\" data-id=\"";
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "');\">Show/Hide</a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.collapseOperationsForResource('"; + "\">Show/Hide</a>\n </li>\n <li>\n <a href='#' class=\"collapseResource\" data-id=\"";
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "'); return false;\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.expandOperationsForResource('"; + "\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' class=\"expandResource\" data-id=";
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "'); return false;\">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='"; + ">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";
if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
@ -1203,18 +1218,18 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
// Generated by CoffeeScript 1.5.0 // Generated by CoffeeScript 1.6.3
(function() { (function() {
var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi, var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi, _ref, _ref1, _ref10, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
__hasProp = {}.hasOwnProperty, __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
SwaggerUi = (function(_super) { SwaggerUi = (function(_super) {
__extends(SwaggerUi, _super); __extends(SwaggerUi, _super);
function SwaggerUi() { function SwaggerUi() {
SwaggerUi.__super__.constructor.apply(this, arguments); _ref = SwaggerUi.__super__.constructor.apply(this, arguments);
return _ref;
} }
SwaggerUi.prototype.dom_id = "swagger_ui"; SwaggerUi.prototype.dom_id = "swagger_ui";
@ -1263,9 +1278,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}; };
SwaggerUi.prototype.load = function() { SwaggerUi.prototype.load = function() {
var url, _ref; var url, _ref1;
if ((_ref = this.mainView) != null) { if ((_ref1 = this.mainView) != null) {
_ref.clear(); _ref1.clear();
} }
url = this.options.url; url = this.options.url;
if (url.indexOf("http") !== 0) { if (url.indexOf("http") !== 0) {
@ -1281,10 +1296,10 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
SwaggerUi.prototype.render = function() { SwaggerUi.prototype.render = function() {
var _this = this; var _this = this;
this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...'); this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
this.headerView.updateInfo(this.api.info);
this.mainView = new MainView({ this.mainView = new MainView({
model: this.api, model: this.api,
el: $('#' + this.dom_id) el: $('#' + this.dom_id),
swaggerOptions: this.options
}).render(); }).render();
this.showMessage(); this.showMessage();
switch (this.options.docExpansion) { switch (this.options.docExpansion) {
@ -1355,11 +1370,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
window.SwaggerUi = SwaggerUi; window.SwaggerUi = SwaggerUi;
HeaderView = (function(_super) { HeaderView = (function(_super) {
__extends(HeaderView, _super); __extends(HeaderView, _super);
function HeaderView() { function HeaderView() {
HeaderView.__super__.constructor.apply(this, arguments); _ref1 = HeaderView.__super__.constructor.apply(this, arguments);
return _ref1;
} }
HeaderView.prototype.events = { HeaderView.prototype.events = {
@ -1412,40 +1427,56 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
} }
}; };
HeaderView.prototype.updateInfo = function(info) {
if (info.title != null) {
$('#logo').text(info.title);
}
if (info.description != null) {
$('#logo').attr('title', info.description);
}
if (info.termsOfServiceUrl != null) {
return $('#logo').attr('href', info.termsOfServiceUrl);
}
};
return HeaderView; return HeaderView;
})(Backbone.View); })(Backbone.View);
MainView = (function(_super) { MainView = (function(_super) {
var sorters;
__extends(MainView, _super); __extends(MainView, _super);
function MainView() { function MainView() {
MainView.__super__.constructor.apply(this, arguments); _ref2 = MainView.__super__.constructor.apply(this, arguments);
return _ref2;
} }
MainView.prototype.initialize = function() {}; sorters = {
'alpha': function(a, b) {
return a.path.localeCompare(b.path);
},
'method': function(a, b) {
return a.method.localeCompare(b.method);
}
};
MainView.prototype.initialize = function(opts) {
var route, sorter, sorterName, _i, _len, _ref3;
if (opts == null) {
opts = {};
}
if (opts.swaggerOptions.sorter) {
sorterName = opts.swaggerOptions.sorter;
sorter = sorters[sorterName];
_ref3 = this.model.apisArray;
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
route = _ref3[_i];
route.operationsArray.sort(sorter);
}
if (sorterName === "alpha") {
return this.model.apisArray.sort(sorter);
}
}
};
MainView.prototype.render = function() { MainView.prototype.render = function() {
var counter, id, resource, resources, _i, _len, _ref; var counter, id, resource, resources, _i, _len, _ref3;
$(this.el).html(Handlebars.templates.main(this.model)); $(this.el).html(Handlebars.templates.main(this.model));
resources = {}; resources = {};
counter = 0; counter = 0;
_ref = this.model.apisArray; _ref3 = this.model.apisArray;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
resource = _ref[_i]; resource = _ref3[_i];
id = resource.name; id = resource.name;
while (typeof resources[id] !== 'undefined') { while (typeof resources[id] !== 'undefined') {
id = id + "_" + counter; id = id + "_" + counter;
@ -1464,7 +1495,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
model: resource, model: resource,
tagName: 'li', tagName: 'li',
id: 'resource_' + resource.id, id: 'resource_' + resource.id,
className: 'resource' className: 'resource',
swaggerOptions: this.options.swaggerOptions
}); });
return $('#resources').append(resourceView.render().el); return $('#resources').append(resourceView.render().el);
}; };
@ -1478,22 +1510,22 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
})(Backbone.View); })(Backbone.View);
ResourceView = (function(_super) { ResourceView = (function(_super) {
__extends(ResourceView, _super); __extends(ResourceView, _super);
function ResourceView() { function ResourceView() {
ResourceView.__super__.constructor.apply(this, arguments); _ref3 = ResourceView.__super__.constructor.apply(this, arguments);
return _ref3;
} }
ResourceView.prototype.initialize = function() {}; ResourceView.prototype.initialize = function() {};
ResourceView.prototype.render = function() { ResourceView.prototype.render = function() {
var counter, id, methods, operation, _i, _len, _ref; var counter, id, methods, operation, _i, _len, _ref4;
$(this.el).html(Handlebars.templates.resource(this.model)); $(this.el).html(Handlebars.templates.resource(this.model));
methods = {}; methods = {};
_ref = this.model.operationsArray; _ref4 = this.model.operationsArray;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
operation = _ref[_i]; operation = _ref4[_i];
counter = 0; counter = 0;
id = operation.nickname; id = operation.nickname;
while (typeof methods[id] !== 'undefined') { while (typeof methods[id] !== 'undefined') {
@ -1505,6 +1537,10 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
operation.parentId = this.model.id; operation.parentId = this.model.id;
this.addOperation(operation); this.addOperation(operation);
} }
$('.toggleEndpointList', this.el).click(this.callDocs.bind(this, 'toggleEndpointListForResource'));
$('.collapseResource', this.el).click(this.callDocs.bind(this, 'collapseOperationsForResource'));
/* DOL_CHANGE LDR Fix typo error that break expand */
$('.expandResource', this.el).click(this.callDocs.bind(this, 'expandOperationsForResource'));
return this; return this;
}; };
@ -1514,22 +1550,28 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
operationView = new OperationView({ operationView = new OperationView({
model: operation, model: operation,
tagName: 'li', tagName: 'li',
className: 'endpoint' className: 'endpoint',
swaggerOptions: this.options.swaggerOptions
}); });
$('.endpoints', $(this.el)).append(operationView.render().el); $('.endpoints', $(this.el)).append(operationView.render().el);
return this.number++; return this.number++;
}; };
ResourceView.prototype.callDocs = function(fnName, e) {
e.preventDefault();
return Docs[fnName](e.currentTarget.getAttribute('data-id'));
};
return ResourceView; return ResourceView;
})(Backbone.View); })(Backbone.View);
OperationView = (function(_super) { OperationView = (function(_super) {
__extends(OperationView, _super); __extends(OperationView, _super);
function OperationView() { function OperationView() {
OperationView.__super__.constructor.apply(this, arguments); _ref4 = OperationView.__super__.constructor.apply(this, arguments);
return _ref4;
} }
OperationView.prototype.invocationUrl = null; OperationView.prototype.invocationUrl = null;
@ -1548,8 +1590,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
OperationView.prototype.mouseEnter = function(e) { OperationView.prototype.mouseEnter = function(e) {
var elem, hgh, pos, scMaxX, scMaxY, scX, scY, wd, x, y; var elem, hgh, pos, scMaxX, scMaxY, scX, scY, wd, x, y;
elem = $(e.currentTarget.parentNode).find('#api_information_panel'); elem = $(e.currentTarget.parentNode).find('#api_information_panel');
x = event.pageX; x = e.pageX;
y = event.pageY; y = e.pageY;
scX = $(window).scrollLeft(); scX = $(window).scrollLeft();
scY = $(window).scrollTop(); scY = $(window).scrollTop();
scMaxX = scX + $(window).width(); scMaxX = scX + $(window).width();
@ -1580,16 +1622,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}; };
OperationView.prototype.render = function() { OperationView.prototype.render = function() {
var contentTypeModel, isMethodSubmissionSupported, k, o, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, v, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3; var contentTypeModel, isMethodSubmissionSupported, k, o, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, v, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8;
isMethodSubmissionSupported = true; isMethodSubmissionSupported = true;
if (!isMethodSubmissionSupported) { if (!isMethodSubmissionSupported) {
this.model.isReadOnly = true; this.model.isReadOnly = true;
} }
this.model.oauth = null; this.model.oauth = null;
if (this.model.authorizations) { if (this.model.authorizations) {
_ref = this.model.authorizations; _ref5 = this.model.authorizations;
for (k in _ref) { for (k in _ref5) {
v = _ref[k]; v = _ref5[k];
if (k === "oauth2") { if (k === "oauth2") {
if (this.model.oauth === null) { if (this.model.oauth === null) {
this.model.oauth = {}; this.model.oauth = {};
@ -1624,9 +1666,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}; };
contentTypeModel.consumes = this.model.consumes; contentTypeModel.consumes = this.model.consumes;
contentTypeModel.produces = this.model.produces; contentTypeModel.produces = this.model.produces;
_ref1 = this.model.parameters; _ref6 = this.model.parameters;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
param = _ref1[_j]; param = _ref6[_j];
type = param.type || param.dataType; type = param.type || param.dataType;
if (type.toLowerCase() === 'file') { if (type.toLowerCase() === 'file') {
if (!contentTypeModel.consumes) { if (!contentTypeModel.consumes) {
@ -1639,14 +1681,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
model: contentTypeModel model: contentTypeModel
}); });
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el); $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
_ref2 = this.model.parameters; _ref7 = this.model.parameters;
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
param = _ref2[_k]; param = _ref7[_k];
this.addParameter(param, contentTypeModel.consumes); this.addParameter(param, contentTypeModel.consumes);
} }
_ref3 = this.model.responseMessages; _ref8 = this.model.responseMessages;
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) { for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
statusCode = _ref3[_l]; statusCode = _ref8[_l];
this.addStatusCode(statusCode); this.addStatusCode(statusCode);
} }
return this; return this;
@ -1673,7 +1715,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}; };
OperationView.prototype.submitOperation = function(e) { OperationView.prototype.submitOperation = function(e) {
var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2; var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7;
if (e != null) { if (e != null) {
e.preventDefault(); e.preventDefault();
} }
@ -1698,9 +1740,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
parent: this parent: this
}; };
isFileUpload = false; isFileUpload = false;
_ref = form.find("input"); _ref5 = form.find("input");
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
o = _ref[_i]; o = _ref5[_i];
if ((o.value != null) && jQuery.trim(o.value).length > 0) { if ((o.value != null) && jQuery.trim(o.value).length > 0) {
map[o.name] = o.value; map[o.name] = o.value;
} }
@ -1708,16 +1750,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
isFileUpload = true; isFileUpload = true;
} }
} }
_ref1 = form.find("textarea"); _ref6 = form.find("textarea");
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
o = _ref1[_j]; o = _ref6[_j];
if ((o.value != null) && jQuery.trim(o.value).length > 0) { if ((o.value != null) && jQuery.trim(o.value).length > 0) {
map["body"] = o.value; map["body"] = o.value;
} }
} }
_ref2 = form.find("select"); _ref7 = form.find("select");
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
o = _ref2[_k]; o = _ref7[_k];
val = this.getSelectedValue(o); val = this.getSelectedValue(o);
if ((val != null) && jQuery.trim(val).length > 0) { if ((val != null) && jQuery.trim(val).length > 0) {
map[o.name] = val; map[o.name] = val;
@ -1739,46 +1781,46 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}; };
OperationView.prototype.handleFileUpload = function(map, form) { OperationView.prototype.handleFileUpload = function(map, form) {
var bodyParam, el, headerParams, o, obj, param, params, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, var bodyParam, el, headerParams, o, obj, param, params, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8,
_this = this; _this = this;
_ref = form.serializeArray(); _ref5 = form.serializeArray();
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
o = _ref[_i]; o = _ref5[_i];
if ((o.value != null) && jQuery.trim(o.value).length > 0) { if ((o.value != null) && jQuery.trim(o.value).length > 0) {
map[o.name] = o.value; map[o.name] = o.value;
} }
} }
bodyParam = new FormData(); bodyParam = new FormData();
params = 0; params = 0;
_ref1 = this.model.parameters; _ref6 = this.model.parameters;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
param = _ref1[_j]; param = _ref6[_j];
if (param.paramType === 'form') { if (param.paramType === 'form') {
if (map[param.name] !== void 0) { if (param.type.toLowerCase() !== 'file' && map[param.name] !== void 0) {
bodyParam.append(param.name, map[param.name]); bodyParam.append(param.name, map[param.name]);
} }
} }
} }
headerParams = {}; headerParams = {};
_ref2 = this.model.parameters; _ref7 = this.model.parameters;
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
param = _ref2[_k]; param = _ref7[_k];
if (param.paramType === 'header') { if (param.paramType === 'header') {
headerParams[param.name] = map[param.name]; headerParams[param.name] = map[param.name];
} }
} }
log(headerParams); log(headerParams);
_ref3 = form.find('input[type~="file"]'); _ref8 = form.find('input[type~="file"]');
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) { for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
el = _ref3[_l]; el = _ref8[_l];
if (typeof el.files[0] !== 'undefined') { if (typeof el.files[0] !== 'undefined') {
bodyParam.append($(el).attr('name'), el.files[0]); bodyParam.append($(el).attr('name'), el.files[0]);
params += 1; params += 1;
} }
} }
log(bodyParam);
this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true); this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true);
$(".request_url", $(this.el)).html("<pre>" + this.invocationUrl + "</pre>"); $(".request_url", $(this.el)).html("<pre></pre>");
$(".request_url pre", $(this.el)).text(this.invocationUrl);
obj = { obj = {
type: this.model.method, type: this.model.method,
url: this.invocationUrl, url: this.invocationUrl,
@ -1829,14 +1871,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}; };
OperationView.prototype.getSelectedValue = function(select) { OperationView.prototype.getSelectedValue = function(select) {
var opt, options, _i, _len, _ref; var opt, options, _i, _len, _ref5;
if (!select.multiple) { if (!select.multiple) {
return select.value; return select.value;
} else { } else {
options = []; options = [];
_ref = select.options; _ref5 = select.options;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
opt = _ref[_i]; opt = _ref5[_i];
if (opt.selected) { if (opt.selected) {
options.push(opt.value); options.push(opt.value);
} }
@ -1924,9 +1966,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
padding = ''; padding = '';
indent += transitions[fromTo]; indent += transitions[fromTo];
padding = ((function() { padding = ((function() {
var _j, _ref, _results; var _j, _ref5, _results;
_results = []; _results = [];
for (j = _j = 0, _ref = indent; 0 <= _ref ? _j < _ref : _j > _ref; j = 0 <= _ref ? ++_j : --_j) { for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
_results.push(' '); _results.push(' ');
} }
return _results; return _results;
@ -1945,7 +1987,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}; };
OperationView.prototype.showStatus = function(response) { OperationView.prototype.showStatus = function(response) {
var code, content, contentType, headers, pre, response_body, url; var code, content, contentType, headers, opts, pre, response_body, response_body_el, url;
if (response.content === void 0) { if (response.content === void 0) {
content = response.data; content = response.data;
url = response.url; url = response.url;
@ -1974,14 +2016,21 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
pre = $('<pre class="json" />').append(code); pre = $('<pre class="json" />').append(code);
} }
response_body = pre; response_body = pre;
$(".request_url", $(this.el)).html("<pre>" + url + "</pre>"); $(".request_url", $(this.el)).html("<pre></pre>");
$(".request_url pre", $(this.el)).text(url);
$(".response_code", $(this.el)).html("<pre>" + response.status + "</pre>"); $(".response_code", $(this.el)).html("<pre>" + response.status + "</pre>");
$(".response_body", $(this.el)).html(response_body); $(".response_body", $(this.el)).html(response_body);
$(".response_headers", $(this.el)).html("<pre>" + JSON.stringify(response.headers, null, " ").replace(/\n/g, "<br>") + "</pre>"); $(".response_headers", $(this.el)).html("<pre>" + _.escape(JSON.stringify(response.headers, null, " ")).replace(/\n/g, "<br>") + "</pre>");
$(".response", $(this.el)).slideDown(); $(".response", $(this.el)).slideDown();
$(".response_hider", $(this.el)).show(); $(".response_hider", $(this.el)).show();
$(".response_throbber", $(this.el)).hide(); $(".response_throbber", $(this.el)).hide();
return hljs.highlightBlock($('.response_body', $(this.el))[0]); response_body_el = $('.response_body', $(this.el))[0];
opts = this.options.swaggerOptions;
if (opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold) {
return response_body_el;
} else {
return hljs.highlightBlock(response_body_el);
}
}; };
OperationView.prototype.toggleOperationContent = function() { OperationView.prototype.toggleOperationContent = function() {
@ -1999,11 +2048,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
})(Backbone.View); })(Backbone.View);
StatusCodeView = (function(_super) { StatusCodeView = (function(_super) {
__extends(StatusCodeView, _super); __extends(StatusCodeView, _super);
function StatusCodeView() { function StatusCodeView() {
StatusCodeView.__super__.constructor.apply(this, arguments); _ref5 = StatusCodeView.__super__.constructor.apply(this, arguments);
return _ref5;
} }
StatusCodeView.prototype.initialize = function() {}; StatusCodeView.prototype.initialize = function() {};
@ -2038,11 +2087,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
})(Backbone.View); })(Backbone.View);
ParameterView = (function(_super) { ParameterView = (function(_super) {
__extends(ParameterView, _super); __extends(ParameterView, _super);
function ParameterView() { function ParameterView() {
ParameterView.__super__.constructor.apply(this, arguments); _ref6 = ParameterView.__super__.constructor.apply(this, arguments);
return _ref6;
} }
ParameterView.prototype.initialize = function() { ParameterView.prototype.initialize = function() {
@ -2127,11 +2176,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
})(Backbone.View); })(Backbone.View);
SignatureView = (function(_super) { SignatureView = (function(_super) {
__extends(SignatureView, _super); __extends(SignatureView, _super);
function SignatureView() { function SignatureView() {
SignatureView.__super__.constructor.apply(this, arguments); _ref7 = SignatureView.__super__.constructor.apply(this, arguments);
return _ref7;
} }
SignatureView.prototype.events = { SignatureView.prototype.events = {
@ -2146,7 +2195,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
var template; var template;
template = this.template(); template = this.template();
$(this.el).html(template(this.model)); $(this.el).html(template(this.model));
this.switchToDescription(); this.switchToSnippet();
this.isParam = this.model.isParam; this.isParam = this.model.isParam;
if (this.isParam) { if (this.isParam) {
$('.notice', $(this.el)).text('Click to set as parameter value'); $('.notice', $(this.el)).text('Click to set as parameter value');
@ -2196,11 +2245,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
})(Backbone.View); })(Backbone.View);
ContentTypeView = (function(_super) { ContentTypeView = (function(_super) {
__extends(ContentTypeView, _super); __extends(ContentTypeView, _super);
function ContentTypeView() { function ContentTypeView() {
ContentTypeView.__super__.constructor.apply(this, arguments); _ref8 = ContentTypeView.__super__.constructor.apply(this, arguments);
return _ref8;
} }
ContentTypeView.prototype.initialize = function() {}; ContentTypeView.prototype.initialize = function() {};
@ -2222,11 +2271,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
})(Backbone.View); })(Backbone.View);
ResponseContentTypeView = (function(_super) { ResponseContentTypeView = (function(_super) {
__extends(ResponseContentTypeView, _super); __extends(ResponseContentTypeView, _super);
function ResponseContentTypeView() { function ResponseContentTypeView() {
ResponseContentTypeView.__super__.constructor.apply(this, arguments); _ref9 = ResponseContentTypeView.__super__.constructor.apply(this, arguments);
return _ref9;
} }
ResponseContentTypeView.prototype.initialize = function() {}; ResponseContentTypeView.prototype.initialize = function() {};
@ -2248,11 +2297,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
})(Backbone.View); })(Backbone.View);
ParameterContentTypeView = (function(_super) { ParameterContentTypeView = (function(_super) {
__extends(ParameterContentTypeView, _super); __extends(ParameterContentTypeView, _super);
function ParameterContentTypeView() { function ParameterContentTypeView() {
ParameterContentTypeView.__super__.constructor.apply(this, arguments); _ref10 = ParameterContentTypeView.__super__.constructor.apply(this, arguments);
return _ref10;
} }
ParameterContentTypeView.prototype.initialize = function() {}; ParameterContentTypeView.prototype.initialize = function() {};

File diff suppressed because one or more lines are too long