mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Update swagger to 2.0.24
This commit is contained in:
parent
6d4c5e4b4a
commit
f011197e00
137
COPYRIGHT
137
COPYRIGHT
|
|
@ -21,13 +21,13 @@ GeoIP 1.4 LGPL-2.1+ Yes
|
|||
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)
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
|
@ -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
|
||||
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
|
||||
SwaggerUI 2.0.24 GPL-2+ Yes JS library to offer the REST API explorer
|
||||
|
||||
For licenses compatibility informations:
|
||||
http://www.gnu.org/licenses/licenses.en.html
|
||||
|
||||
|
||||
Copyright
|
||||
---------
|
||||
|
||||
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>
|
||||
|
||||
|
||||
|
||||
|
||||
Copyright / Authors
|
||||
-------------------
|
||||
|
||||
See page https://github.com/Dolibarr/dolibarr/graphs/contributors
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@
|
|||
font-size: .85em;
|
||||
line-height: 1.2em;
|
||||
overflow: auto;
|
||||
max-height: 400px;
|
||||
max-height: 200px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav {
|
||||
|
|
@ -743,17 +743,20 @@
|
|||
display: inline-block;
|
||||
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 {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: left;
|
||||
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 {
|
||||
outline: 2px solid black;
|
||||
outline-color: #cc0000;
|
||||
|
|
@ -1158,7 +1161,7 @@
|
|||
cursor: pointer;
|
||||
}
|
||||
.swagger-section #header {
|
||||
background-color: #646257;
|
||||
background-color: #89bf04;
|
||||
padding: 14px;
|
||||
}
|
||||
.swagger-section #header a#logo {
|
||||
|
|
@ -1193,7 +1196,7 @@
|
|||
padding: 6px 8px;
|
||||
font-size: 0.9em;
|
||||
color: white;
|
||||
background-color: #000000;
|
||||
background-color: #547f00;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
-o-border-radius: 4px;
|
||||
|
|
@ -1202,35 +1205,13 @@
|
|||
border-radius: 4px;
|
||||
}
|
||||
.swagger-section #header form#api_selector .input a#explore:hover {
|
||||
background-color: #a41e22;
|
||||
background-color: #547f00;
|
||||
}
|
||||
.swagger-section #header form#api_selector .input input {
|
||||
font-size: 0.9em;
|
||||
padding: 3px;
|
||||
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 {
|
||||
margin: 10px 15px;
|
||||
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 |
|
|
@ -2,8 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<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'/>
|
||||
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">-->
|
||||
<!-- DOL_CHANGE LDR Remove external links <link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' 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/reset.css' media='print' rel='stylesheet' type='text/css'/>
|
||||
|
|
@ -27,10 +26,11 @@
|
|||
$(function () {
|
||||
window.swaggerUi = new SwaggerUi({
|
||||
url: "resources.json",
|
||||
validatorUrl: null,
|
||||
dom_id: "swagger-ui-container",
|
||||
supportedSubmitMethods: ['get', 'post', 'put', 'patch', 'delete'],
|
||||
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||
onComplete: function(swaggerApi, swaggerUi){
|
||||
log("Loaded Api Explorer");
|
||||
log("Loaded API Explorer");
|
||||
|
||||
if(typeof initOAuth == "function") {
|
||||
/*
|
||||
|
|
@ -45,15 +45,19 @@
|
|||
hljs.highlightBlock(e)
|
||||
});
|
||||
},
|
||||
defaultModelRendering: 'model',
|
||||
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() {
|
||||
var key = $('#input_apiKey')[0].value;
|
||||
|
||||
log("key: " + key);
|
||||
if(key && key.trim() != "") {
|
||||
/* DOL_CHANGE LDR We set DOLAPIKEY into header */
|
||||
log("added key " + key);
|
||||
|
|
@ -67,11 +71,15 @@
|
|||
console.log("header DOLAPIKEY added with value "+key);
|
||||
}
|
||||
})
|
||||
|
||||
window.swaggerUi.load();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.info_title, .info_description, .info_contact, .info_license {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="swagger-section">
|
||||
|
|
@ -79,6 +87,14 @@
|
|||
<div class="swagger-ui-wrap">
|
||||
<a id="logo" href="#">API Explorer</a>
|
||||
<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="DOLAPIKEY" id="input_apiKey" name="apiKey" type="text"/></div>
|
||||
<div class='input'><a id="explore" href="#">Explore</a></div>
|
||||
|
|
|
|||
|
|
@ -48,72 +48,65 @@ function handleLogin() {
|
|||
str += '</label></li>';
|
||||
popup.append(str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var $win = $(window),
|
||||
dw = $win.width(),
|
||||
dh = $win.height(),
|
||||
st = $win.scrollTop(),
|
||||
dlgWd = popupDialog.outerWidth(),
|
||||
dlgHt = popupDialog.outerHeight(),
|
||||
top = (dh -dlgHt)/2 + st,
|
||||
left = (dw - dlgWd)/2;
|
||||
var $win = $(window),
|
||||
dw = $win.width(),
|
||||
dh = $win.height(),
|
||||
st = $win.scrollTop(),
|
||||
dlgWd = popupDialog.outerWidth(),
|
||||
dlgHt = popupDialog.outerHeight(),
|
||||
top = (dh -dlgHt)/2 + st,
|
||||
left = (dw - dlgWd)/2;
|
||||
|
||||
popupDialog.css({
|
||||
top: (top < 0? 0 : top) + 'px',
|
||||
left: (left < 0? 0 : left) + 'px'
|
||||
});
|
||||
popupDialog.css({
|
||||
top: (top < 0? 0 : top) + 'px',
|
||||
left: (left < 0? 0 : left) + 'px'
|
||||
});
|
||||
|
||||
popupDialog.find('button.api-popup-cancel').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
});
|
||||
popupDialog.find('button.api-popup-authbtn').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
popupDialog.find('button.api-popup-cancel').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
});
|
||||
popupDialog.find('button.api-popup-authbtn').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var location = window.location;
|
||||
var locationUrl = location.protocol + '//' + location.host + location.pathname;
|
||||
var redirectUrl = locationUrl.replace("index.html","").concat("/o2c.html").replace("//o2c.html","/o2c.html");
|
||||
var url = null;
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var host = window.location;
|
||||
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
|
||||
var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html";
|
||||
var url = null;
|
||||
|
||||
var p = window.swaggerUi.api.authSchemes;
|
||||
for (var key in p) {
|
||||
if (p.hasOwnProperty(key)) {
|
||||
var o = p[key].grantTypes;
|
||||
for(var t in o) {
|
||||
if(o.hasOwnProperty(t) && t === 'implicit') {
|
||||
var dets = o[t];
|
||||
url = dets.loginEndpoint.url + "?response_type=token";
|
||||
window.swaggerUi.tokenName = dets.tokenName;
|
||||
}
|
||||
for (var key in authSchemes) {
|
||||
if (authSchemes.hasOwnProperty(key)) {
|
||||
var o = authSchemes[key].grantTypes;
|
||||
for(var t in o) {
|
||||
if(o.hasOwnProperty(t) && t === 'implicit') {
|
||||
var dets = o[t];
|
||||
url = dets.loginEndpoint.url + "?response_type=token";
|
||||
window.swaggerUi.tokenName = dets.tokenName;
|
||||
}
|
||||
}
|
||||
}
|
||||
var scopes = [];
|
||||
var scopeForUrl='';
|
||||
var o = $('.api-popup-scopes').find('input:checked');
|
||||
}
|
||||
var scopes = []
|
||||
var o = $('.api-popup-scopes').find('input:checked');
|
||||
|
||||
for(var k =0; k < o.length; k++) {
|
||||
scopes.push($(o[k]).attr("scope"));
|
||||
if(k > 0){
|
||||
scopeForUrl+=' ';
|
||||
}
|
||||
scopeForUrl+=$(o[k]).attr("scope");
|
||||
}
|
||||
for(k =0; k < o.length; k++) {
|
||||
scopes.push($(o[k]).attr("scope"));
|
||||
}
|
||||
|
||||
window.enabledScopes=scopes;
|
||||
|
||||
window.enabledScopes=scopes;
|
||||
|
||||
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
|
||||
url += '&realm=' + encodeURIComponent(realm);
|
||||
url += '&client_id=' + encodeURIComponent(clientId);
|
||||
url += '&scope=' + encodeURIComponent(scopeForUrl);
|
||||
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
|
||||
url += '&realm=' + encodeURIComponent(realm);
|
||||
url += '&client_id=' + encodeURIComponent(clientId);
|
||||
url += '&scope=' + encodeURIComponent(scopes);
|
||||
|
||||
window.open(url);
|
||||
});
|
||||
|
||||
window.open(url);
|
||||
});
|
||||
}
|
||||
popupMask.show();
|
||||
popupDialog.show();
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// swagger.js
|
||||
// version 2.0.30
|
||||
// version 2.0.39
|
||||
|
||||
var __bind = function(fn, me){
|
||||
return function(){
|
||||
|
|
@ -11,10 +11,20 @@ log = function(){
|
|||
log.history = log.history || [];
|
||||
log.history.push(arguments);
|
||||
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) {
|
||||
Array.prototype.indexOf = function(obj, start) {
|
||||
for (var i = (start || 0), j = this.length; i < j; i++) {
|
||||
|
|
@ -45,48 +55,50 @@ if (!('map' in Array.prototype)) {
|
|||
}
|
||||
|
||||
Object.keys = Object.keys || (function () {
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
|
||||
DontEnums = [
|
||||
'toString',
|
||||
'toLocaleString',
|
||||
'valueOf',
|
||||
'hasOwnProperty',
|
||||
'isPrototypeOf',
|
||||
'propertyIsEnumerable',
|
||||
'constructor'
|
||||
],
|
||||
DontEnumsLength = DontEnums.length;
|
||||
|
||||
return function (o) {
|
||||
if (typeof o != "object" && typeof o != "function" || o === null)
|
||||
throw new TypeError("Object.keys called on a non-object");
|
||||
|
||||
var result = [];
|
||||
for (var name in o) {
|
||||
if (hasOwnProperty.call(o, name))
|
||||
result.push(name);
|
||||
}
|
||||
|
||||
if (hasDontEnumBug) {
|
||||
for (var i = 0; i < DontEnumsLength; i++) {
|
||||
if (hasOwnProperty.call(o, DontEnums[i]))
|
||||
result.push(DontEnums[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
|
||||
DontEnums = [
|
||||
'toString',
|
||||
'toLocaleString',
|
||||
'valueOf',
|
||||
'hasOwnProperty',
|
||||
'isPrototypeOf',
|
||||
'propertyIsEnumerable',
|
||||
'constructor'
|
||||
],
|
||||
DontEnumsLength = DontEnums.length;
|
||||
|
||||
return function (o) {
|
||||
if (typeof o != "object" && typeof o != "function" || o === null)
|
||||
throw new TypeError("Object.keys called on a non-object");
|
||||
|
||||
var result = [];
|
||||
for (var name in o) {
|
||||
if (hasOwnProperty.call(o, name))
|
||||
result.push(name);
|
||||
}
|
||||
|
||||
if (hasDontEnumBug) {
|
||||
for (var i = 0; i < DontEnumsLength; i++) {
|
||||
if (hasOwnProperty.call(o, DontEnums[i]))
|
||||
result.push(DontEnums[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
var SwaggerApi = function(url, options) {
|
||||
this.isBuilt = false;
|
||||
this.url = null;
|
||||
this.debug = false;
|
||||
this.basePath = null;
|
||||
this.authorizations = null;
|
||||
this.authorizationScheme = null;
|
||||
this.info = null;
|
||||
this.useJQuery = false;
|
||||
this.modelsArray = [];
|
||||
|
||||
options = (options||{});
|
||||
if (url)
|
||||
|
|
@ -103,13 +115,20 @@ var SwaggerApi = function(url, options) {
|
|||
if (options.success != null)
|
||||
this.success = options.success;
|
||||
|
||||
if (typeof options.useJQuery === 'boolean')
|
||||
this.useJQuery = options.useJQuery;
|
||||
|
||||
this.failure = options.failure != null ? options.failure : function() {};
|
||||
this.progress = options.progress != null ? options.progress : function() {};
|
||||
if (options.success != null)
|
||||
if (options.success != null) {
|
||||
this.build();
|
||||
this.isBuilt = true;
|
||||
}
|
||||
}
|
||||
|
||||
SwaggerApi.prototype.build = function() {
|
||||
if(this.isBuilt)
|
||||
return this;
|
||||
var _this = this;
|
||||
this.progress('fetching resource list: ' + this.url);
|
||||
var obj = {
|
||||
|
|
@ -117,7 +136,7 @@ SwaggerApi.prototype.build = function() {
|
|||
url: this.url,
|
||||
method: "get",
|
||||
headers: {
|
||||
accept: "application/json"
|
||||
accept: "application/json,application/json;charset=\"utf-8\",*/*"
|
||||
},
|
||||
on: {
|
||||
error: function(response) {
|
||||
|
|
@ -154,6 +173,7 @@ SwaggerApi.prototype.buildFromSpec = function(response) {
|
|||
}
|
||||
this.apis = {};
|
||||
this.apisArray = [];
|
||||
this.consumes = response.consumes;
|
||||
this.produces = response.produces;
|
||||
this.authSchemes = response.authorizations;
|
||||
if (response.info != null) {
|
||||
|
|
@ -171,13 +191,13 @@ SwaggerApi.prototype.buildFromSpec = function(response) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (response.basePath) {
|
||||
if (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('?'));
|
||||
} else {
|
||||
else
|
||||
this.basePath = this.url;
|
||||
}
|
||||
|
||||
if (isApi) {
|
||||
var newName = response.resourcePath.replace(/\//g, '');
|
||||
this.resourcePath = response.resourcePath;
|
||||
|
|
@ -272,7 +292,6 @@ SwaggerApi.prototype.fail = function(message) {
|
|||
|
||||
SwaggerApi.prototype.setConsolidatedModels = function() {
|
||||
var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
|
||||
this.modelsArray = [];
|
||||
this.models = {};
|
||||
_ref = this.apis;
|
||||
for (resource_name in _ref) {
|
||||
|
|
@ -317,8 +336,8 @@ var SwaggerResource = function(resourceObj, api) {
|
|||
var _this = this;
|
||||
this.api = api;
|
||||
this.api = this.api;
|
||||
produces = [];
|
||||
consumes = [];
|
||||
consumes = (this.consumes | []);
|
||||
produces = (this.produces | []);
|
||||
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
||||
this.description = resourceObj.description;
|
||||
|
||||
|
|
@ -349,7 +368,7 @@ var SwaggerResource = function(resourceObj, api) {
|
|||
method: "get",
|
||||
useJQuery: this.useJQuery,
|
||||
headers: {
|
||||
accept: "application/json"
|
||||
accept: "application/json,application/json;charset=\"utf-8\",*/*"
|
||||
},
|
||||
on: {
|
||||
response: function(resp) {
|
||||
|
|
@ -368,22 +387,28 @@ var SwaggerResource = function(resourceObj, api) {
|
|||
}
|
||||
}
|
||||
|
||||
SwaggerResource.prototype.getAbsoluteBasePath = function(relativeBasePath) {
|
||||
var parts, pos, url;
|
||||
SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {
|
||||
var pos, url;
|
||||
url = this.api.basePath;
|
||||
pos = url.lastIndexOf(relativeBasePath);
|
||||
if (pos === -1) {
|
||||
parts = url.split("/");
|
||||
url = parts[0] + "//" + parts[2];
|
||||
if (relativeBasePath.indexOf("/") === 0) {
|
||||
return url + relativeBasePath;
|
||||
} else {
|
||||
return url + "/" + relativeBasePath;
|
||||
}
|
||||
} else if (relativeBasePath === "/") {
|
||||
return url.substring(0, pos);
|
||||
} else {
|
||||
return url.substring(0, pos) + relativeBasePath;
|
||||
var parts = url.split("/");
|
||||
var rootUrl = parts[0] + "//" + parts[2];
|
||||
|
||||
if(relativeBasePath.indexOf("http") === 0)
|
||||
return relativeBasePath;
|
||||
if(relativeBasePath === "/")
|
||||
return rootUrl;
|
||||
if(relativeBasePath.substring(0, 1) == "/") {
|
||||
// use root + relative
|
||||
return rootUrl + relativeBasePath;
|
||||
}
|
||||
else {
|
||||
var pos = this.basePath.lastIndexOf("/");
|
||||
var base = this.basePath.substring(0, pos);
|
||||
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) {
|
||||
var op;
|
||||
op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|./?,\\'""-]/g, '_');
|
||||
//'
|
||||
op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_');
|
||||
op = op.replace(/((_){2,})/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.descr = obj.description;
|
||||
this.required = obj.required;
|
||||
this.defaultValue = modelPropertyMacro(obj.defaultValue);
|
||||
if (obj.items != null) {
|
||||
if (obj.items.type != null) {
|
||||
this.refDataType = obj.items.type;
|
||||
|
|
@ -629,7 +654,9 @@ SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
|
|||
|
||||
SwaggerModelProperty.prototype.toSampleValue = function(value) {
|
||||
var result;
|
||||
if (value === "integer") {
|
||||
if ((typeof this.defaultValue !== 'undefined') && this.defaultValue !== null) {
|
||||
result = this.defaultValue;
|
||||
} else if (value === "integer") {
|
||||
result = 0;
|
||||
} else if (value === "boolean") {
|
||||
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) {
|
||||
return _this["do"](args, callback, error);
|
||||
|
|
@ -812,7 +840,7 @@ SwaggerOperation.prototype.getSampleJSON = function(type, models) {
|
|||
else
|
||||
return JSON.stringify(val, null, 2);
|
||||
}
|
||||
else
|
||||
else
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
|
@ -1073,7 +1101,7 @@ SwaggerOperation.prototype.formatXml = function(xml) {
|
|||
var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) {
|
||||
var _this = this;
|
||||
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.url = (url||errors.push("SwaggerRequest url is required."));
|
||||
this.params = params;
|
||||
|
|
@ -1090,96 +1118,59 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
|||
|
||||
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 parent = params["parent"];
|
||||
var requestContentType = "application/json";
|
||||
|
||||
var formParams = [];
|
||||
var fileParams = [];
|
||||
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 = {};
|
||||
// encode the body for form submits
|
||||
if (headers["Content-Type"]) {
|
||||
var values = {};
|
||||
var key;
|
||||
for(key in formParams){
|
||||
var param = formParams[key];
|
||||
values[param.name] = param;
|
||||
var i;
|
||||
var operationParams = this.operation.parameters;
|
||||
for(i = 0; i < operationParams.length; i++) {
|
||||
var param = operationParams[i];
|
||||
if(param.paramType === "form")
|
||||
values[param.name] = param;
|
||||
}
|
||||
|
||||
var encoded = "";
|
||||
var key;
|
||||
for(key in values) {
|
||||
value = this.params[key];
|
||||
if(typeof value !== 'undefined'){
|
||||
if(encoded !== "")
|
||||
encoded += "&";
|
||||
encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
||||
if(headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
var encoded = "";
|
||||
var key;
|
||||
for(key in values) {
|
||||
value = this.params[key];
|
||||
if(typeof value !== 'undefined'){
|
||||
if(encoded !== "")
|
||||
encoded += "&";
|
||||
encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
||||
}
|
||||
}
|
||||
body = encoded;
|
||||
}
|
||||
else if (headers["Content-Type"].indexOf("multipart/form-data") === 0) {
|
||||
// encode the body for form submits
|
||||
var data = "";
|
||||
var boundary = "----SwaggerFormBoundary" + Date.now();
|
||||
var key;
|
||||
for(key in values) {
|
||||
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;
|
||||
}
|
||||
body = encoded;
|
||||
}
|
||||
var name;
|
||||
for (name in this.headers)
|
||||
myHeaders[name] = this.headers[name];
|
||||
if ((requestContentType && body !== "") || (requestContentType === "application/x-www-form-urlencoded"))
|
||||
myHeaders["Content-Type"] = requestContentType;
|
||||
if (responseContentType)
|
||||
myHeaders["Accept"] = responseContentType;
|
||||
|
||||
if (!((this.headers != null) && (this.headers.mock != null))) {
|
||||
obj = {
|
||||
url: this.url,
|
||||
method: this.type,
|
||||
headers: myHeaders,
|
||||
headers: headers,
|
||||
body: body,
|
||||
useJQuery: this.useJQuery,
|
||||
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() {
|
||||
var results = [];
|
||||
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) {
|
||||
var cb = obj.on;
|
||||
|
|
@ -1335,8 +1404,8 @@ JQueryHttpClient.prototype.execute = function(obj) {
|
|||
return cb.response(out);
|
||||
};
|
||||
|
||||
$.support.cors = true;
|
||||
return $.ajax(obj);
|
||||
jQuery.support.cors = true;
|
||||
return jQuery.ajax(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1411,11 +1480,36 @@ ShredHttpClient.prototype.execute = function(obj) {
|
|||
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 = {
|
||||
error: function(response) {
|
||||
if (obj)
|
||||
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) {
|
||||
if (obj)
|
||||
return cb.redirect(transform(response));
|
||||
|
|
@ -1452,26 +1546,42 @@ SwaggerAuthorizations.prototype.remove = function(name) {
|
|||
};
|
||||
|
||||
SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
|
||||
status = null;
|
||||
var status = null;
|
||||
var key;
|
||||
for (key in this.authz) {
|
||||
value = this.authz[key];
|
||||
result = value.apply(obj, authorizations);
|
||||
if (result === false)
|
||||
status = false;
|
||||
if (result === true)
|
||||
status = true;
|
||||
|
||||
// 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) {
|
||||
value = this.authz[key];
|
||||
result = value.apply(obj, authorizations);
|
||||
if (result === 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;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.value = value;
|
||||
this.type = type;
|
||||
this.delimiter = delimiter;
|
||||
};
|
||||
|
||||
ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
|
|
@ -1482,7 +1592,12 @@ ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
|
|||
obj.url = obj.url + "?" + this.name + "=" + this.value;
|
||||
return true;
|
||||
} else if (this.type === "header") {
|
||||
obj.headers[this.name] = this.value;
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// swagger-ui.js
|
||||
// version 2.0.17
|
||||
// version 2.0.23
|
||||
$(function() {
|
||||
|
||||
// Helper function for vertically aligning DOM elements
|
||||
|
|
@ -68,7 +68,7 @@ log = function(){
|
|||
log.history = log.history || [];
|
||||
log.history.push(arguments);
|
||||
if(this.console){
|
||||
console.log( Array.prototype.slice.call(arguments) );
|
||||
console.log( Array.prototype.slice.call(arguments)[0] );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -240,67 +240,74 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
function program1(depth0,data) {
|
||||
|
||||
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});
|
||||
if(stack2 || stack2 === 0) { buffer += stack2; }
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data});
|
||||
if(stack2 || stack2 === 0) { buffer += stack2; }
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license), {hash:{},inverse:self.noop,fn:self.program(6, program6, data),data:data});
|
||||
if(stack2 || stack2 === 0) { buffer += stack2; }
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
return buffer;
|
||||
}
|
||||
function program2(depth0,data) {
|
||||
|
||||
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))
|
||||
+ "\" title=\"Terms of Service\"><i class=\"fa fa-lg fa-bullhorn\"></i> Terms</a></li>";
|
||||
+ "\">Terms of service</a></div>";
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function program4(depth0,data) {
|
||||
|
||||
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))
|
||||
+ "\"><i class=\"fa fa-lg fa-send\"></i> Contact</a></li>";
|
||||
+ "\">Contact the developer</a></div>";
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function program6(depth0,data) {
|
||||
|
||||
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))
|
||||
+ "\" title=\""
|
||||
+ "'>"
|
||||
+ 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;
|
||||
}
|
||||
|
||||
function program8(depth0,data) {
|
||||
|
||||
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}); }
|
||||
else { stack1 = depth0.apiVersion; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1);
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "\n ";
|
||||
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});
|
||||
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}); }
|
||||
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});
|
||||
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;
|
||||
});
|
||||
})();
|
||||
|
|
@ -389,7 +396,7 @@ function program18(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='";
|
||||
|
|
@ -555,7 +562,7 @@ function program9(depth0,data) {
|
|||
|
||||
var buffer = "", stack1;
|
||||
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; }
|
||||
buffer += "\n ";
|
||||
return buffer;
|
||||
|
|
@ -563,7 +570,16 @@ function program9(depth0,data) {
|
|||
function program10(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n <input class='parameter' minlength='0' name='";
|
||||
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;
|
||||
buffer += "\n <input class='parameter' minlength='0' name='";
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
|
|
@ -571,18 +587,18 @@ function program10(depth0,data) {
|
|||
if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "'/>\n ";
|
||||
+ "'/>\n ";
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function program12(depth0,data) {
|
||||
function program13(depth0,data) {
|
||||
|
||||
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}); }
|
||||
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "' placeholder='' type='text' value=''/>\n ";
|
||||
+ "' placeholder='' type='text' value=''/>\n ";
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
@ -1057,23 +1073,19 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
|
||||
function program1(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += " : ";
|
||||
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;
|
||||
|
||||
return " : ";
|
||||
}
|
||||
|
||||
buffer += "<div class='heading'>\n <h2>\n <a href='#!/";
|
||||
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "' onclick=\"Docs.toggleEndpointListForResource('";
|
||||
+ "' class=\"toggleEndpointList\" data-id=\"";
|
||||
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "');\">";
|
||||
+ "\">";
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
|
|
@ -1083,6 +1095,9 @@ function program1(depth0,data) {
|
|||
else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
if (!helpers.description) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
|
||||
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='#!/";
|
||||
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
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}); }
|
||||
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "'\n onclick=\"Docs.toggleEndpointListForResource('";
|
||||
+ "' class=\"toggleEndpointList\" data-id=\"";
|
||||
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : 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}); }
|
||||
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : 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}); }
|
||||
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : 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}); }
|
||||
else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : 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() {
|
||||
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,
|
||||
__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) {
|
||||
|
||||
__extends(SwaggerUi, _super);
|
||||
|
||||
function SwaggerUi() {
|
||||
SwaggerUi.__super__.constructor.apply(this, arguments);
|
||||
_ref = SwaggerUi.__super__.constructor.apply(this, arguments);
|
||||
return _ref;
|
||||
}
|
||||
|
||||
SwaggerUi.prototype.dom_id = "swagger_ui";
|
||||
|
|
@ -1263,9 +1278,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
};
|
||||
|
||||
SwaggerUi.prototype.load = function() {
|
||||
var url, _ref;
|
||||
if ((_ref = this.mainView) != null) {
|
||||
_ref.clear();
|
||||
var url, _ref1;
|
||||
if ((_ref1 = this.mainView) != null) {
|
||||
_ref1.clear();
|
||||
}
|
||||
url = this.options.url;
|
||||
if (url.indexOf("http") !== 0) {
|
||||
|
|
@ -1281,10 +1296,10 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
SwaggerUi.prototype.render = function() {
|
||||
var _this = this;
|
||||
this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
|
||||
this.headerView.updateInfo(this.api.info);
|
||||
this.mainView = new MainView({
|
||||
model: this.api,
|
||||
el: $('#' + this.dom_id)
|
||||
el: $('#' + this.dom_id),
|
||||
swaggerOptions: this.options
|
||||
}).render();
|
||||
this.showMessage();
|
||||
switch (this.options.docExpansion) {
|
||||
|
|
@ -1355,11 +1370,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
window.SwaggerUi = SwaggerUi;
|
||||
|
||||
HeaderView = (function(_super) {
|
||||
|
||||
__extends(HeaderView, _super);
|
||||
|
||||
function HeaderView() {
|
||||
HeaderView.__super__.constructor.apply(this, arguments);
|
||||
_ref1 = HeaderView.__super__.constructor.apply(this, arguments);
|
||||
return _ref1;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
})(Backbone.View);
|
||||
|
||||
MainView = (function(_super) {
|
||||
var sorters;
|
||||
|
||||
__extends(MainView, _super);
|
||||
|
||||
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() {
|
||||
var counter, id, resource, resources, _i, _len, _ref;
|
||||
var counter, id, resource, resources, _i, _len, _ref3;
|
||||
$(this.el).html(Handlebars.templates.main(this.model));
|
||||
resources = {};
|
||||
counter = 0;
|
||||
_ref = this.model.apisArray;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
resource = _ref[_i];
|
||||
_ref3 = this.model.apisArray;
|
||||
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
|
||||
resource = _ref3[_i];
|
||||
id = resource.name;
|
||||
while (typeof resources[id] !== 'undefined') {
|
||||
id = id + "_" + counter;
|
||||
|
|
@ -1464,7 +1495,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
model: resource,
|
||||
tagName: 'li',
|
||||
id: 'resource_' + resource.id,
|
||||
className: 'resource'
|
||||
className: 'resource',
|
||||
swaggerOptions: this.options.swaggerOptions
|
||||
});
|
||||
return $('#resources').append(resourceView.render().el);
|
||||
};
|
||||
|
|
@ -1478,22 +1510,22 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
})(Backbone.View);
|
||||
|
||||
ResourceView = (function(_super) {
|
||||
|
||||
__extends(ResourceView, _super);
|
||||
|
||||
function ResourceView() {
|
||||
ResourceView.__super__.constructor.apply(this, arguments);
|
||||
_ref3 = ResourceView.__super__.constructor.apply(this, arguments);
|
||||
return _ref3;
|
||||
}
|
||||
|
||||
ResourceView.prototype.initialize = 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));
|
||||
methods = {};
|
||||
_ref = this.model.operationsArray;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
operation = _ref[_i];
|
||||
_ref4 = this.model.operationsArray;
|
||||
for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
|
||||
operation = _ref4[_i];
|
||||
counter = 0;
|
||||
id = operation.nickname;
|
||||
while (typeof methods[id] !== 'undefined') {
|
||||
|
|
@ -1505,6 +1537,10 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
operation.parentId = this.model.id;
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
@ -1514,22 +1550,28 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
operationView = new OperationView({
|
||||
model: operation,
|
||||
tagName: 'li',
|
||||
className: 'endpoint'
|
||||
className: 'endpoint',
|
||||
swaggerOptions: this.options.swaggerOptions
|
||||
});
|
||||
$('.endpoints', $(this.el)).append(operationView.render().el);
|
||||
return this.number++;
|
||||
};
|
||||
|
||||
ResourceView.prototype.callDocs = function(fnName, e) {
|
||||
e.preventDefault();
|
||||
return Docs[fnName](e.currentTarget.getAttribute('data-id'));
|
||||
};
|
||||
|
||||
return ResourceView;
|
||||
|
||||
})(Backbone.View);
|
||||
|
||||
OperationView = (function(_super) {
|
||||
|
||||
__extends(OperationView, _super);
|
||||
|
||||
function OperationView() {
|
||||
OperationView.__super__.constructor.apply(this, arguments);
|
||||
_ref4 = OperationView.__super__.constructor.apply(this, arguments);
|
||||
return _ref4;
|
||||
}
|
||||
|
||||
OperationView.prototype.invocationUrl = null;
|
||||
|
|
@ -1548,8 +1590,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
OperationView.prototype.mouseEnter = function(e) {
|
||||
var elem, hgh, pos, scMaxX, scMaxY, scX, scY, wd, x, y;
|
||||
elem = $(e.currentTarget.parentNode).find('#api_information_panel');
|
||||
x = event.pageX;
|
||||
y = event.pageY;
|
||||
x = e.pageX;
|
||||
y = e.pageY;
|
||||
scX = $(window).scrollLeft();
|
||||
scY = $(window).scrollTop();
|
||||
scMaxX = scX + $(window).width();
|
||||
|
|
@ -1580,16 +1622,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
};
|
||||
|
||||
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;
|
||||
if (!isMethodSubmissionSupported) {
|
||||
this.model.isReadOnly = true;
|
||||
}
|
||||
this.model.oauth = null;
|
||||
if (this.model.authorizations) {
|
||||
_ref = this.model.authorizations;
|
||||
for (k in _ref) {
|
||||
v = _ref[k];
|
||||
_ref5 = this.model.authorizations;
|
||||
for (k in _ref5) {
|
||||
v = _ref5[k];
|
||||
if (k === "oauth2") {
|
||||
if (this.model.oauth === null) {
|
||||
this.model.oauth = {};
|
||||
|
|
@ -1624,9 +1666,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
};
|
||||
contentTypeModel.consumes = this.model.consumes;
|
||||
contentTypeModel.produces = this.model.produces;
|
||||
_ref1 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
param = _ref1[_j];
|
||||
_ref6 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
param = _ref6[_j];
|
||||
type = param.type || param.dataType;
|
||||
if (type.toLowerCase() === 'file') {
|
||||
if (!contentTypeModel.consumes) {
|
||||
|
|
@ -1639,14 +1681,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
model: contentTypeModel
|
||||
});
|
||||
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
|
||||
_ref2 = this.model.parameters;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
param = _ref2[_k];
|
||||
_ref7 = this.model.parameters;
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
param = _ref7[_k];
|
||||
this.addParameter(param, contentTypeModel.consumes);
|
||||
}
|
||||
_ref3 = this.model.responseMessages;
|
||||
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
|
||||
statusCode = _ref3[_l];
|
||||
_ref8 = this.model.responseMessages;
|
||||
for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
|
||||
statusCode = _ref8[_l];
|
||||
this.addStatusCode(statusCode);
|
||||
}
|
||||
return this;
|
||||
|
|
@ -1673,7 +1715,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
};
|
||||
|
||||
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) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
|
@ -1698,9 +1740,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
parent: this
|
||||
};
|
||||
isFileUpload = false;
|
||||
_ref = form.find("input");
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
o = _ref[_i];
|
||||
_ref5 = form.find("input");
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
o = _ref5[_i];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = o.value;
|
||||
}
|
||||
|
|
@ -1708,16 +1750,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
isFileUpload = true;
|
||||
}
|
||||
}
|
||||
_ref1 = form.find("textarea");
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
o = _ref1[_j];
|
||||
_ref6 = form.find("textarea");
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
o = _ref6[_j];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map["body"] = o.value;
|
||||
}
|
||||
}
|
||||
_ref2 = form.find("select");
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
o = _ref2[_k];
|
||||
_ref7 = form.find("select");
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
o = _ref7[_k];
|
||||
val = this.getSelectedValue(o);
|
||||
if ((val != null) && jQuery.trim(val).length > 0) {
|
||||
map[o.name] = val;
|
||||
|
|
@ -1739,46 +1781,46 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
};
|
||||
|
||||
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;
|
||||
_ref = form.serializeArray();
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
o = _ref[_i];
|
||||
_ref5 = form.serializeArray();
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
o = _ref5[_i];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = o.value;
|
||||
}
|
||||
}
|
||||
bodyParam = new FormData();
|
||||
params = 0;
|
||||
_ref1 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
param = _ref1[_j];
|
||||
_ref6 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
param = _ref6[_j];
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
headerParams = {};
|
||||
_ref2 = this.model.parameters;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
param = _ref2[_k];
|
||||
_ref7 = this.model.parameters;
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
param = _ref7[_k];
|
||||
if (param.paramType === 'header') {
|
||||
headerParams[param.name] = map[param.name];
|
||||
}
|
||||
}
|
||||
log(headerParams);
|
||||
_ref3 = form.find('input[type~="file"]');
|
||||
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
|
||||
el = _ref3[_l];
|
||||
_ref8 = form.find('input[type~="file"]');
|
||||
for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
|
||||
el = _ref8[_l];
|
||||
if (typeof el.files[0] !== 'undefined') {
|
||||
bodyParam.append($(el).attr('name'), el.files[0]);
|
||||
params += 1;
|
||||
}
|
||||
}
|
||||
log(bodyParam);
|
||||
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 = {
|
||||
type: this.model.method,
|
||||
url: this.invocationUrl,
|
||||
|
|
@ -1829,14 +1871,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
};
|
||||
|
||||
OperationView.prototype.getSelectedValue = function(select) {
|
||||
var opt, options, _i, _len, _ref;
|
||||
var opt, options, _i, _len, _ref5;
|
||||
if (!select.multiple) {
|
||||
return select.value;
|
||||
} else {
|
||||
options = [];
|
||||
_ref = select.options;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
opt = _ref[_i];
|
||||
_ref5 = select.options;
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
opt = _ref5[_i];
|
||||
if (opt.selected) {
|
||||
options.push(opt.value);
|
||||
}
|
||||
|
|
@ -1924,9 +1966,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
padding = '';
|
||||
indent += transitions[fromTo];
|
||||
padding = ((function() {
|
||||
var _j, _ref, _results;
|
||||
var _j, _ref5, _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(' ');
|
||||
}
|
||||
return _results;
|
||||
|
|
@ -1945,7 +1987,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
};
|
||||
|
||||
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) {
|
||||
content = response.data;
|
||||
url = response.url;
|
||||
|
|
@ -1974,14 +2016,21 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
pre = $('<pre class="json" />').append(code);
|
||||
}
|
||||
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_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_hider", $(this.el)).show();
|
||||
$(".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() {
|
||||
|
|
@ -1999,11 +2048,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
})(Backbone.View);
|
||||
|
||||
StatusCodeView = (function(_super) {
|
||||
|
||||
__extends(StatusCodeView, _super);
|
||||
|
||||
function StatusCodeView() {
|
||||
StatusCodeView.__super__.constructor.apply(this, arguments);
|
||||
_ref5 = StatusCodeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref5;
|
||||
}
|
||||
|
||||
StatusCodeView.prototype.initialize = function() {};
|
||||
|
|
@ -2038,11 +2087,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
})(Backbone.View);
|
||||
|
||||
ParameterView = (function(_super) {
|
||||
|
||||
__extends(ParameterView, _super);
|
||||
|
||||
function ParameterView() {
|
||||
ParameterView.__super__.constructor.apply(this, arguments);
|
||||
_ref6 = ParameterView.__super__.constructor.apply(this, arguments);
|
||||
return _ref6;
|
||||
}
|
||||
|
||||
ParameterView.prototype.initialize = function() {
|
||||
|
|
@ -2127,11 +2176,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
})(Backbone.View);
|
||||
|
||||
SignatureView = (function(_super) {
|
||||
|
||||
__extends(SignatureView, _super);
|
||||
|
||||
function SignatureView() {
|
||||
SignatureView.__super__.constructor.apply(this, arguments);
|
||||
_ref7 = SignatureView.__super__.constructor.apply(this, arguments);
|
||||
return _ref7;
|
||||
}
|
||||
|
||||
SignatureView.prototype.events = {
|
||||
|
|
@ -2146,7 +2195,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
var template;
|
||||
template = this.template();
|
||||
$(this.el).html(template(this.model));
|
||||
this.switchToDescription();
|
||||
this.switchToSnippet();
|
||||
this.isParam = this.model.isParam;
|
||||
if (this.isParam) {
|
||||
$('.notice', $(this.el)).text('Click to set as parameter value');
|
||||
|
|
@ -2196,11 +2245,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
})(Backbone.View);
|
||||
|
||||
ContentTypeView = (function(_super) {
|
||||
|
||||
__extends(ContentTypeView, _super);
|
||||
|
||||
function ContentTypeView() {
|
||||
ContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
_ref8 = ContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref8;
|
||||
}
|
||||
|
||||
ContentTypeView.prototype.initialize = function() {};
|
||||
|
|
@ -2222,11 +2271,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
})(Backbone.View);
|
||||
|
||||
ResponseContentTypeView = (function(_super) {
|
||||
|
||||
__extends(ResponseContentTypeView, _super);
|
||||
|
||||
function ResponseContentTypeView() {
|
||||
ResponseContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
_ref9 = ResponseContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref9;
|
||||
}
|
||||
|
||||
ResponseContentTypeView.prototype.initialize = function() {};
|
||||
|
|
@ -2248,11 +2297,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
})(Backbone.View);
|
||||
|
||||
ParameterContentTypeView = (function(_super) {
|
||||
|
||||
__extends(ParameterContentTypeView, _super);
|
||||
|
||||
function ParameterContentTypeView() {
|
||||
ParameterContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
_ref10 = ParameterContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref10;
|
||||
}
|
||||
|
||||
ParameterContentTypeView.prototype.initialize = function() {};
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user