Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9955bcc69f | ||
|
|
c17cc1010f | ||
|
|
2de104aac9 | ||
|
|
fbe5278928 | ||
|
|
b09a8e91c9 | ||
|
|
c3904c54c8 | ||
|
|
26db2ce375 | ||
|
|
c948b40d34 | ||
|
|
5d2bed7025 | ||
|
|
6dc12f733e | ||
|
|
dfd5e937d4 | ||
|
|
9d0417e7f2 | ||
|
|
8ad46f0813 | ||
|
|
db6419414c | ||
|
|
9b9b5b4551 | ||
|
|
50ded295d9 | ||
|
|
525241fcd2 | ||
|
|
855b31d73b | ||
|
|
7945dec86c | ||
|
|
011f70935d | ||
|
|
f0a099728c | ||
|
|
d673d5d1cb | ||
|
|
8ad843fc4f | ||
|
|
1b89ab4128 | ||
|
|
bfc0c987df | ||
|
|
e250ab3e66 | ||
|
|
25c33cb472 | ||
|
|
b8e4317929 | ||
|
|
c2dd77ff3a | ||
|
|
4b535adcb7 | ||
|
|
05588bb669 | ||
|
|
f7694d8525 | ||
|
|
d96fd58016 | ||
|
|
8d0c9107e7 | ||
|
|
1f3746a846 | ||
|
|
9cedc0b4d7 | ||
|
|
ca47551d93 | ||
|
|
15afbcf14f | ||
|
|
34ab47e9e7 | ||
|
|
84f4e670fc | ||
|
|
f6380d17e5 | ||
|
|
52db742a10 | ||
|
|
a536583890 | ||
|
|
a36da91d7e | ||
|
|
96c14e43a9 | ||
|
|
2edd7ac058 | ||
|
|
da63a33845 | ||
|
|
579abd6848 | ||
|
|
99b3f7d00e |
@@ -65,22 +65,28 @@ task 'dist', 'Build a distribution', ->
|
||||
throw err if err
|
||||
fs.unlink 'dist/_swagger-ui.coffee'
|
||||
console.log ' : Combining with javascript...'
|
||||
exec 'cat src/main/javascript/doc.js dist/_swagger-ui-templates.js dist/_swagger-ui.js > dist/swagger-ui.js', (err, stdout, stderr) ->
|
||||
throw err if err
|
||||
fs.unlink 'dist/_swagger-ui.js'
|
||||
fs.unlink 'dist/_swagger-ui-templates.js'
|
||||
console.log ' : Minifying all...'
|
||||
exec 'java -jar "./bin/yuicompressor-2.4.7.jar" --type js -o ' + 'dist/swagger-ui.min.js ' + 'dist/swagger-ui.js', (err, stdout, stderr) ->
|
||||
|
||||
fs.readFile 'package.json', 'utf8', (err, fileContents) ->
|
||||
obj = JSON.parse(fileContents)
|
||||
exec 'echo "// swagger-ui.js" > dist/swagger-ui.js'
|
||||
exec 'echo "// version ' + obj.version + '" >> dist/swagger-ui.js'
|
||||
exec 'cat src/main/javascript/doc.js dist/_swagger-ui-templates.js dist/_swagger-ui.js >> dist/swagger-ui.js', (err, stdout, stderr) ->
|
||||
throw err if err
|
||||
lessc()
|
||||
fs.unlink 'dist/_swagger-ui.js'
|
||||
fs.unlink 'dist/_swagger-ui-templates.js'
|
||||
console.log ' : Minifying all...'
|
||||
exec 'java -jar "./bin/yuicompressor-2.4.7.jar" --type js -o ' + 'dist/swagger-ui.min.js ' + 'dist/swagger-ui.js', (err, stdout, stderr) ->
|
||||
throw err if err
|
||||
lessc()
|
||||
|
||||
lessc = ->
|
||||
# Someone who knows CoffeeScript should make this more Coffee-licious
|
||||
console.log ' : Compiling LESS...'
|
||||
|
||||
less.render fs.readFileSync("src/main/less/screen.less", 'utf8'), (err, css) ->
|
||||
console.log err
|
||||
fs.writeFileSync("src/main/html/css/screen.css", css)
|
||||
less.render fs.readFileSync("src/main/less/reset.less", 'utf8'), (err, css) ->
|
||||
fs.writeFileSync("src/main/html/css/reset.css", css)
|
||||
pack()
|
||||
|
||||
pack = ->
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
Swagger UI
|
||||
==========
|
||||
# Swagger UI
|
||||
|
||||
Swagger UI is part of [Swagger](http://swagger.wordnik.com/) project. The Swagger project allows you to produce, visualize and consume your OWN RESTful services. No proxy or 3rd party services required. Do it your own way.
|
||||
|
||||
Swagger UI is part of Swagger project. The Swagger project allows you to produce, visualize and consume your OWN RESTful services. No proxy or 3rd party services required. Do it your own way.
|
||||
|
||||
Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically
|
||||
generate beautiful documentation and sandbox from a [Swagger-compliant](https://github.com/wordnik/swagger-core/wiki) API. Because Swagger UI has no dependencies, you can host it in any server environment, or on your local machine.
|
||||
generate beautiful documentation and sandbox from a Swagger-compliant API. Because Swagger UI has no dependencies, you can host it in any server environment, or on your local machine.
|
||||
|
||||
How to Use It
|
||||
-------------
|
||||
## What's Swagger?
|
||||
|
||||
The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swager removes the guesswork in calling the service.
|
||||
|
||||
|
||||
Check out [Swagger-Spec](https://github.com/wordnik/swagger-spec) for additional information about the Swagger project, including additional libraries with support for other languages and more.
|
||||
|
||||
|
||||
## How to Use It
|
||||
|
||||
### Download
|
||||
You can use the swagger-ui code AS-IS! No need to build or recompile--just clone this repo and use the pre-built files in the `dist` folder. If you like swagger-ui as-is, stop here.
|
||||
@@ -52,6 +59,7 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
|
||||
* *dom_id parameter* is the the id of a dom element inside which SwaggerUi will put the user interface for swagger
|
||||
* *booleanValues* SwaggerUI renders boolean data types as a dropdown. By default it provides a 'true' and 'false' string as the possible choices. You can use this parameter to change the values in dropdown to be something else, for example 0 and 1 by setting booleanValues to new Array(0, 1)
|
||||
* *docExpansion* controls how the API listing is displayed. It can be set to 'none' (default), 'list' (shows operations for each resource), or 'full' (fully expanded: shows operations and their details)
|
||||
* *sorter* apply a sort to the API list. It can be 'alpha' (sort paths alphanumerically) or 'method' (sort operations by HTTP method). Default is the order returned by the server unchanged.
|
||||
* *onComplete* is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully.
|
||||
* *onFailure* is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render.
|
||||
* All other parameters are explained in greater detail below
|
||||
@@ -85,8 +93,7 @@ window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "XXXX"
|
||||
|
||||
Note! You can pass multiple header params on a single request, just use unique names for them (`key` is used in the above example).
|
||||
|
||||
How to Improve It
|
||||
-----------------
|
||||
## How to Improve It
|
||||
|
||||
Create your own fork of [wordnik/swagger-ui](https://github.com/wordnik/swagger-ui)
|
||||
|
||||
@@ -94,8 +101,7 @@ To share your changes, [submit a pull request](https://github.com/wordnik/swagge
|
||||
|
||||
Since the javascript files are compiled from coffeescript, please submit changes in the *.coffee files! We have to reject changes only in the .js files as they will be lost on each build of the ui.
|
||||
|
||||
License
|
||||
-------
|
||||
## License
|
||||
|
||||
Copyright 2011-2013 Wordnik, Inc.
|
||||
|
||||
|
||||
Vendored
+125
@@ -0,0 +1,125 @@
|
||||
/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
|
||||
html,
|
||||
body,
|
||||
div,
|
||||
span,
|
||||
applet,
|
||||
object,
|
||||
iframe,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
p,
|
||||
blockquote,
|
||||
pre,
|
||||
a,
|
||||
abbr,
|
||||
acronym,
|
||||
address,
|
||||
big,
|
||||
cite,
|
||||
code,
|
||||
del,
|
||||
dfn,
|
||||
em,
|
||||
img,
|
||||
ins,
|
||||
kbd,
|
||||
q,
|
||||
s,
|
||||
samp,
|
||||
small,
|
||||
strike,
|
||||
strong,
|
||||
sub,
|
||||
sup,
|
||||
tt,
|
||||
var,
|
||||
b,
|
||||
u,
|
||||
i,
|
||||
center,
|
||||
dl,
|
||||
dt,
|
||||
dd,
|
||||
ol,
|
||||
ul,
|
||||
li,
|
||||
fieldset,
|
||||
form,
|
||||
label,
|
||||
legend,
|
||||
table,
|
||||
caption,
|
||||
tbody,
|
||||
tfoot,
|
||||
thead,
|
||||
tr,
|
||||
th,
|
||||
td,
|
||||
article,
|
||||
aside,
|
||||
canvas,
|
||||
details,
|
||||
embed,
|
||||
figure,
|
||||
figcaption,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
menu,
|
||||
nav,
|
||||
output,
|
||||
ruby,
|
||||
section,
|
||||
summary,
|
||||
time,
|
||||
mark,
|
||||
audio,
|
||||
video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article,
|
||||
aside,
|
||||
details,
|
||||
figcaption,
|
||||
figure,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
menu,
|
||||
nav,
|
||||
section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol,
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote,
|
||||
q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before,
|
||||
blockquote:after,
|
||||
q:before,
|
||||
q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
Vendored
+520
-394
File diff suppressed because it is too large
Load Diff
Vendored
BIN
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
Vendored
+27
-17
@@ -2,9 +2,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Swagger UI</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
||||
<link href='css/highlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||
<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'/>
|
||||
<link href='css/screen.css' media='print' rel='stylesheet' type='text/css'/>
|
||||
<script type="text/javascript" src="lib/shred.bundle.js"></script>
|
||||
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
|
||||
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
|
||||
@@ -16,6 +18,10 @@
|
||||
<script src='lib/swagger.js' type='text/javascript'></script>
|
||||
<script src='swagger-ui.js' type='text/javascript'></script>
|
||||
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
||||
|
||||
<!-- enabling this will enable oauth2 implicit scope support -->
|
||||
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
window.swaggerUi = new SwaggerUi({
|
||||
@@ -23,13 +29,26 @@
|
||||
dom_id: "swagger-ui-container",
|
||||
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||
onComplete: function(swaggerApi, swaggerUi){
|
||||
log("Loaded SwaggerUI")
|
||||
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
|
||||
log("Loaded SwaggerUI");
|
||||
|
||||
if(typeof initOAuth == "function") {
|
||||
/*
|
||||
initOAuth({
|
||||
clientId: "your-client-id",
|
||||
realm: "your-realms",
|
||||
appName: "your-app-name"
|
||||
});
|
||||
*/
|
||||
}
|
||||
$('pre code').each(function(i, e) {
|
||||
hljs.highlightBlock(e)
|
||||
});
|
||||
},
|
||||
onFailure: function(data) {
|
||||
log("Unable to Load SwaggerUI");
|
||||
},
|
||||
docExpansion: "none"
|
||||
docExpansion: "none",
|
||||
sorter : "alpha"
|
||||
});
|
||||
|
||||
$('#input_apiKey').change(function() {
|
||||
@@ -42,15 +61,13 @@
|
||||
})
|
||||
window.swaggerUi.load();
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body class="swagger-section">
|
||||
<div id='header'>
|
||||
<div class="swagger-ui-wrap">
|
||||
<a id="logo" href="http://swagger.wordnik.com">swagger</a>
|
||||
|
||||
<form id='api_selector'>
|
||||
<div class='input icon-btn'>
|
||||
<img id="show-pet-store-icon" src="images/pet_store_api.png" title="Show Swagger Petstore Example Apis">
|
||||
@@ -65,14 +82,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="message-bar" class="swagger-ui-wrap">
|
||||
|
||||
</div>
|
||||
|
||||
<div id="swagger-ui-container" class="swagger-ui-wrap">
|
||||
|
||||
</div>
|
||||
|
||||
<div id="message-bar" class="swagger-ui-wrap"> </div>
|
||||
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
Vendored
+211
@@ -0,0 +1,211 @@
|
||||
var appName;
|
||||
var popupMask;
|
||||
var popupDialog;
|
||||
var clientId;
|
||||
var realm;
|
||||
|
||||
function handleLogin() {
|
||||
var scopes = [];
|
||||
|
||||
if(window.swaggerUi.api.authSchemes
|
||||
&& window.swaggerUi.api.authSchemes.oauth2
|
||||
&& window.swaggerUi.api.authSchemes.oauth2.scopes) {
|
||||
scopes = window.swaggerUi.api.authSchemes.oauth2.scopes;
|
||||
}
|
||||
|
||||
if(window.swaggerUi.api
|
||||
&& window.swaggerUi.api.info) {
|
||||
appName = window.swaggerUi.api.info.title;
|
||||
}
|
||||
|
||||
if(popupDialog.length > 0)
|
||||
popupDialog = popupDialog.last();
|
||||
else {
|
||||
popupDialog = $(
|
||||
[
|
||||
'<div class="api-popup-dialog">',
|
||||
'<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
|
||||
'<div class="api-popup-content">',
|
||||
'<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.',
|
||||
'<a href="#">Learn how to use</a>',
|
||||
'</p>',
|
||||
'<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
|
||||
'<ul class="api-popup-scopes">',
|
||||
'</ul>',
|
||||
'<p class="error-msg"></p>',
|
||||
'<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
|
||||
'</div>',
|
||||
'</div>'].join(''));
|
||||
$(document.body).append(popupDialog);
|
||||
|
||||
popup = popupDialog.find('ul.api-popup-scopes').empty();
|
||||
for (i = 0; i < scopes.length; i ++) {
|
||||
scope = scopes[i];
|
||||
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
|
||||
if (scope.description) {
|
||||
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
|
||||
}
|
||||
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;
|
||||
|
||||
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();
|
||||
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var host = window.location;
|
||||
var redirectUrl = host.protocol + '//' + host.host + "/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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var scopes = []
|
||||
var o = $('.api-popup-scopes').find('input:checked');
|
||||
|
||||
for(k =0; k < o.length; k++) {
|
||||
scopes.push($(o[k]).attr("scope"));
|
||||
}
|
||||
|
||||
window.enabledScopes=scopes;
|
||||
|
||||
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
|
||||
url += '&realm=' + encodeURIComponent(realm);
|
||||
url += '&client_id=' + encodeURIComponent(clientId);
|
||||
url += '&scope=' + encodeURIComponent(scopes);
|
||||
|
||||
window.open(url);
|
||||
});
|
||||
|
||||
popupMask.show();
|
||||
popupDialog.show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
function handleLogout() {
|
||||
for(key in window.authorizations.authz){
|
||||
window.authorizations.remove(key)
|
||||
}
|
||||
window.enabledScopes = null;
|
||||
$('.api-ic.ic-on').addClass('ic-off');
|
||||
$('.api-ic.ic-on').removeClass('ic-on');
|
||||
|
||||
// set the info box
|
||||
$('.api-ic.ic-warning').addClass('ic-error');
|
||||
$('.api-ic.ic-warning').removeClass('ic-warning');
|
||||
}
|
||||
|
||||
function initOAuth(opts) {
|
||||
var o = (opts||{});
|
||||
var errors = [];
|
||||
|
||||
appName = (o.appName||errors.push("missing appName"));
|
||||
popupMask = (o.popupMask||$('#api-common-mask'));
|
||||
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
|
||||
clientId = (o.clientId||errors.push("missing client id"));
|
||||
realm = (o.realm||errors.push("missing realm"));
|
||||
|
||||
if(errors.length > 0){
|
||||
log("auth unable initialize oauth: " + errors);
|
||||
return;
|
||||
}
|
||||
|
||||
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
|
||||
$('.api-ic').click(function(s) {
|
||||
if($(s.target).hasClass('ic-off'))
|
||||
handleLogin();
|
||||
else {
|
||||
handleLogout();
|
||||
}
|
||||
false;
|
||||
});
|
||||
}
|
||||
|
||||
function onOAuthComplete(token) {
|
||||
if(token) {
|
||||
if(token.error) {
|
||||
var checkbox = $('input[type=checkbox],.secured')
|
||||
checkbox.each(function(pos){
|
||||
checkbox[pos].checked = false;
|
||||
});
|
||||
alert(token.error);
|
||||
}
|
||||
else {
|
||||
var b = token[window.swaggerUi.tokenName];
|
||||
if(b){
|
||||
// if all roles are satisfied
|
||||
var o = null;
|
||||
$.each($('.auth #api_information_panel'), function(k, v) {
|
||||
var children = v;
|
||||
if(children && children.childNodes) {
|
||||
var requiredScopes = [];
|
||||
$.each((children.childNodes), function (k1, v1){
|
||||
var inner = v1.innerHTML;
|
||||
if(inner)
|
||||
requiredScopes.push(inner);
|
||||
});
|
||||
var diff = [];
|
||||
for(var i=0; i < requiredScopes.length; i++) {
|
||||
var s = requiredScopes[i];
|
||||
if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) {
|
||||
diff.push(s);
|
||||
}
|
||||
}
|
||||
if(diff.length > 0){
|
||||
o = v.parentNode;
|
||||
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
|
||||
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
|
||||
|
||||
// sorry, not all scopes are satisfied
|
||||
$(o).find('.api-ic').addClass('ic-warning');
|
||||
$(o).find('.api-ic').removeClass('ic-error');
|
||||
}
|
||||
else {
|
||||
o = v.parentNode;
|
||||
$(o.parentNode).find('.api-ic.ic-off').addClass('ic-on');
|
||||
$(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');
|
||||
|
||||
// all scopes are satisfied
|
||||
$(o).find('.api-ic').addClass('ic-info');
|
||||
$(o).find('.api-ic').removeClass('ic-warning');
|
||||
$(o).find('.api-ic').removeClass('ic-error');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.authorizations.add("oauth2", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+324
-121
@@ -1,5 +1,5 @@
|
||||
// swagger.js
|
||||
// version 2.0.26
|
||||
// version 2.0.34
|
||||
|
||||
var __bind = function(fn, me){
|
||||
return function(){
|
||||
@@ -11,7 +11,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] );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,13 +25,13 @@ if (!Array.prototype.indexOf) {
|
||||
}
|
||||
|
||||
if (!('filter' in Array.prototype)) {
|
||||
Array.prototype.filter= function(filter, that /*opt*/) {
|
||||
var other= [], v;
|
||||
for (var i=0, n= this.length; i<n; i++)
|
||||
if (i in this && filter.call(that, v= this[i], i, this))
|
||||
other.push(v);
|
||||
return other;
|
||||
};
|
||||
Array.prototype.filter= function(filter, that /*opt*/) {
|
||||
var other= [], v;
|
||||
for (var i=0, n= this.length; i<n; i++)
|
||||
if (i in this && filter.call(that, v= this[i], i, this))
|
||||
other.push(v);
|
||||
return other;
|
||||
};
|
||||
}
|
||||
|
||||
if (!('map' in Array.prototype)) {
|
||||
@@ -57,24 +57,24 @@ Object.keys = Object.keys || (function () {
|
||||
'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;
|
||||
};
|
||||
})();
|
||||
@@ -87,6 +87,7 @@ var SwaggerApi = function(url, options) {
|
||||
this.authorizations = null;
|
||||
this.authorizationScheme = null;
|
||||
this.info = null;
|
||||
this.useJQuery = false;
|
||||
|
||||
options = (options||{});
|
||||
if (url)
|
||||
@@ -103,6 +104,9 @@ 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)
|
||||
@@ -368,22 +372,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 +488,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, '');
|
||||
@@ -562,15 +571,20 @@ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
|
||||
};
|
||||
|
||||
SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
|
||||
var result = {};
|
||||
var modelsToIgnore = (modelsToIgnore||[])
|
||||
modelsToIgnore.push(this.name);
|
||||
for (var i = 0; i < this.properties.length; i++) {
|
||||
prop = this.properties[i];
|
||||
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
||||
if(sampleModels[this.name]) {
|
||||
return sampleModels[this.name];
|
||||
}
|
||||
else {
|
||||
var result = {};
|
||||
var modelsToIgnore = (modelsToIgnore||[])
|
||||
modelsToIgnore.push(this.name);
|
||||
for (var i = 0; i < this.properties.length; i++) {
|
||||
prop = this.properties[i];
|
||||
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
||||
}
|
||||
modelsToIgnore.pop(this.name);
|
||||
return result;
|
||||
}
|
||||
modelsToIgnore.pop(this.name);
|
||||
return result;
|
||||
};
|
||||
|
||||
var SwaggerModelProperty = function(name, obj) {
|
||||
@@ -793,7 +807,22 @@ SwaggerOperation.prototype.getSampleJSON = function(type, models) {
|
||||
val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
|
||||
if (val) {
|
||||
val = listType ? [val] : val;
|
||||
return JSON.stringify(val, null, 2);
|
||||
if(typeof val == "string")
|
||||
return val;
|
||||
else if(typeof val === "object") {
|
||||
var t = val;
|
||||
if(val instanceof Array && val.length > 0) {
|
||||
t = val[0];
|
||||
}
|
||||
if(t.nodeName) {
|
||||
var xmlString = new XMLSerializer().serializeToString(t);
|
||||
return this.formatXml(xmlString);
|
||||
}
|
||||
else
|
||||
return JSON.stringify(val, null, 2);
|
||||
}
|
||||
else
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -882,6 +911,22 @@ SwaggerOperation.prototype.pathXml = function() {
|
||||
return this.path.replace("{format}", "xml");
|
||||
};
|
||||
|
||||
SwaggerOperation.prototype.encodePathParam = function(pathParam) {
|
||||
var encParts, part, parts, _i, _len;
|
||||
pathParam = pathParam.toString();
|
||||
if (pathParam.indexOf("/") === -1) {
|
||||
return encodeURIComponent(pathParam);
|
||||
} else {
|
||||
parts = pathParam.split("/");
|
||||
encParts = [];
|
||||
for (_i = 0, _len = parts.length; _i < _len; _i++) {
|
||||
part = parts[_i];
|
||||
encParts.push(encodeURIComponent(part));
|
||||
}
|
||||
return encParts.join("/");
|
||||
}
|
||||
};
|
||||
|
||||
SwaggerOperation.prototype.urlify = function(args) {
|
||||
var url = this.resource.basePath + this.pathJson();
|
||||
var params = this.parameters;
|
||||
@@ -891,7 +936,7 @@ SwaggerOperation.prototype.urlify = function(args) {
|
||||
if(args[param.name]) {
|
||||
// apply path params and remove from args
|
||||
var reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
|
||||
url = url.replace(reg, encodeURIComponent(args[param.name]));
|
||||
url = url.replace(reg, this.encodePathParam(args[param.name]));
|
||||
delete args[param.name];
|
||||
}
|
||||
else
|
||||
@@ -960,10 +1005,84 @@ SwaggerOperation.prototype.help = function() {
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
SwaggerOperation.prototype.formatXml = function(xml) {
|
||||
var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
|
||||
reg = /(>)(<)(\/*)/g;
|
||||
wsexp = /[ ]*(.*)[ ]+\n/g;
|
||||
contexp = /(<.+>)(.+\n)/g;
|
||||
xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
|
||||
pad = 0;
|
||||
formatted = '';
|
||||
lines = xml.split('\n');
|
||||
indent = 0;
|
||||
lastType = 'other';
|
||||
transitions = {
|
||||
'single->single': 0,
|
||||
'single->closing': -1,
|
||||
'single->opening': 0,
|
||||
'single->other': 0,
|
||||
'closing->single': 0,
|
||||
'closing->closing': -1,
|
||||
'closing->opening': 0,
|
||||
'closing->other': 0,
|
||||
'opening->single': 1,
|
||||
'opening->closing': 0,
|
||||
'opening->opening': 1,
|
||||
'opening->other': 1,
|
||||
'other->single': 0,
|
||||
'other->closing': -1,
|
||||
'other->opening': 0,
|
||||
'other->other': 0
|
||||
};
|
||||
_fn = function(ln) {
|
||||
var fromTo, j, key, padding, type, types, value;
|
||||
types = {
|
||||
single: Boolean(ln.match(/<.+\/>/)),
|
||||
closing: Boolean(ln.match(/<\/.+>/)),
|
||||
opening: Boolean(ln.match(/<[^!?].*>/))
|
||||
};
|
||||
type = ((function() {
|
||||
var _results;
|
||||
_results = [];
|
||||
for (key in types) {
|
||||
value = types[key];
|
||||
if (value) {
|
||||
_results.push(key);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
})())[0];
|
||||
type = type === void 0 ? 'other' : type;
|
||||
fromTo = lastType + '->' + type;
|
||||
lastType = type;
|
||||
padding = '';
|
||||
indent += transitions[fromTo];
|
||||
padding = ((function() {
|
||||
var _j, _ref5, _results;
|
||||
_results = [];
|
||||
for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
|
||||
_results.push(' ');
|
||||
}
|
||||
return _results;
|
||||
})()).join('');
|
||||
if (fromTo === 'opening->closing') {
|
||||
return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
|
||||
} else {
|
||||
return formatted += padding + ln + '\n';
|
||||
}
|
||||
};
|
||||
for (_i = 0, _len = lines.length; _i < _len; _i++) {
|
||||
ln = lines[_i];
|
||||
_fn(ln);
|
||||
}
|
||||
return formatted;
|
||||
};
|
||||
|
||||
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;
|
||||
@@ -980,62 +1099,12 @@ 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) {
|
||||
// encode the body for form submits
|
||||
if (headers["Accept"] && headers["Accept"].indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
var fields = {};
|
||||
var possibleParams = {};
|
||||
var values = {};
|
||||
@@ -1057,19 +1126,12 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
||||
}
|
||||
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: {
|
||||
@@ -1106,6 +1168,99 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
||||
}
|
||||
};
|
||||
|
||||
SwaggerRequest.prototype.setHeaders = function(params, operation) {
|
||||
// default type
|
||||
var accepts = "application/json";
|
||||
var contentType = null;
|
||||
|
||||
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)
|
||||
accepts = this.opts.requestContentType;
|
||||
} else {
|
||||
// if any form params, content type must be set
|
||||
if(definedFormParams.length > 0) {
|
||||
if(definedFileParams.length > 0)
|
||||
accepts = "multipart/form-data";
|
||||
else
|
||||
accepts = "application/x-www-form-urlencoded";
|
||||
}
|
||||
else if (this.type == "DELETE")
|
||||
body = "{}";
|
||||
else if (this.type != "DELETE")
|
||||
accepts = null;
|
||||
}
|
||||
|
||||
if (contentType && this.operation.consumes) {
|
||||
if (this.operation.consumes.indexOf(contentType) === -1) {
|
||||
log("server doesn't consume " + contentType + ", try " + JSON.stringify(this.operation.consumes));
|
||||
contentType = 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 (contentType && contentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
var fields = {};
|
||||
var possibleParams = {};
|
||||
var values = {};
|
||||
var key;
|
||||
for(key in formParams){
|
||||
var param = formParams[key];
|
||||
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);
|
||||
}
|
||||
}
|
||||
body = encoded;
|
||||
}
|
||||
if ((contentType && body !== "") || (contentType === "application/x-www-form-urlencoded"))
|
||||
headers["Content-Type"] = contentType;
|
||||
if (accepts)
|
||||
headers["Accept"] = accepts;
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
SwaggerRequest.prototype.asCurl = function() {
|
||||
var results = [];
|
||||
if(this.headers) {
|
||||
@@ -1149,9 +1304,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;
|
||||
@@ -1180,14 +1342,25 @@ JQueryHttpClient.prototype.execute = function(obj) {
|
||||
|
||||
obj.data = obj.body;
|
||||
obj.complete = function(response, textStatus, opts) {
|
||||
headers = {};
|
||||
headerArray = response.getAllResponseHeaders().split(":");
|
||||
var headers = {},
|
||||
headerArray = response.getAllResponseHeaders().split("\n");
|
||||
|
||||
for(var i = 0; i < headerArray.length / 2; i++)
|
||||
headers[headerArray[i] = headerArray[i+1]];
|
||||
for(var i = 0; i < headerArray.length; i++) {
|
||||
var toSplit = headerArray[i].trim();
|
||||
if(toSplit.length === 0)
|
||||
continue;
|
||||
var separator = toSplit.indexOf(":");
|
||||
if(separator === -1) {
|
||||
// Name but no value in the header
|
||||
headers[toSplit] = null;
|
||||
continue;
|
||||
}
|
||||
var name = toSplit.substring(0, separator).trim(),
|
||||
value = toSplit.substring(separator + 1).trim();
|
||||
headers[name] = value;
|
||||
}
|
||||
|
||||
out = {
|
||||
headers: headers,
|
||||
var out = {
|
||||
url: request.url,
|
||||
method: request.method,
|
||||
status: response.status,
|
||||
@@ -1214,8 +1387,8 @@ JQueryHttpClient.prototype.execute = function(obj) {
|
||||
return cb.response(out);
|
||||
};
|
||||
|
||||
$.support.cors = true;
|
||||
return $.ajax(obj);
|
||||
jQuery.support.cors = true;
|
||||
return jQuery.ajax(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1331,16 +1504,31 @@ 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;
|
||||
};
|
||||
|
||||
@@ -1366,6 +1554,16 @@ ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
}
|
||||
};
|
||||
|
||||
var CookieAuthorization = function(cookie) {
|
||||
this.cookie = cookie;
|
||||
}
|
||||
|
||||
CookieAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
obj.cookieJar = obj.cookieJar || CookieJar();
|
||||
obj.cookieJar.setCookie(this.cookie);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Password Authorization is a basic auth implementation
|
||||
*/
|
||||
@@ -1388,11 +1586,16 @@ PasswordAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
|
||||
var e = (typeof window !== 'undefined' ? window : exports);
|
||||
|
||||
var sampleModels = {};
|
||||
var cookies = {};
|
||||
|
||||
e.SampleModels = sampleModels;
|
||||
e.SwaggerHttp = SwaggerHttp;
|
||||
e.SwaggerRequest = SwaggerRequest;
|
||||
e.authorizations = new SwaggerAuthorizations();
|
||||
e.ApiKeyAuthorization = ApiKeyAuthorization;
|
||||
e.PasswordAuthorization = PasswordAuthorization;
|
||||
e.CookieAuthorization = CookieAuthorization;
|
||||
e.JQueryHttpClient = JQueryHttpClient;
|
||||
e.ShredHttpClient = ShredHttpClient;
|
||||
e.SwaggerOperation = SwaggerOperation;
|
||||
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
<script>
|
||||
var qp = null;
|
||||
if(window.location.hash) {
|
||||
qp = location.hash.substring(1);
|
||||
}
|
||||
else {
|
||||
qp = location.search.substring(1);
|
||||
}
|
||||
qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
|
||||
function(key, value) {
|
||||
return key===""?value:decodeURIComponent(value) }
|
||||
):{}
|
||||
window.opener.onOAuthComplete(qp);
|
||||
window.close();
|
||||
</script>
|
||||
Vendored
+213
-39
@@ -1,3 +1,5 @@
|
||||
// swagger-ui.js
|
||||
// version 2.0.19
|
||||
$(function() {
|
||||
|
||||
// Helper function for vertically aligning DOM elements
|
||||
@@ -66,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] );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -315,7 +317,7 @@ function program8(depth0,data) {
|
||||
templates['operation'] = template(function (Handlebars,depth0,helpers,partials,data) {
|
||||
this.compilerInfo = [4,'>= 1.0.0'];
|
||||
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
|
||||
var buffer = "", stack1, options, functionType="function", escapeExpression=this.escapeExpression, self=this, blockHelperMissing=helpers.blockHelperMissing;
|
||||
|
||||
function program1(depth0,data) {
|
||||
|
||||
@@ -331,28 +333,67 @@ function program1(depth0,data) {
|
||||
function program3(depth0,data) {
|
||||
|
||||
|
||||
return "\n <h4>Response Class</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"response-content-type\" />\n ";
|
||||
return "\n <div class=\"auth\">\n <span class=\"api-ic ic-error\"></span>";
|
||||
}
|
||||
|
||||
function program5(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n <div id=\"api_information_panel\" style=\"top: 526px; left: 776px; display: none;\">\n ";
|
||||
stack1 = helpers.each.call(depth0, depth0, {hash:{},inverse:self.noop,fn:self.program(6, program6, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n </div>\n ";
|
||||
return buffer;
|
||||
}
|
||||
function program6(depth0,data) {
|
||||
|
||||
var buffer = "", stack1, stack2;
|
||||
buffer += "\n <div title='";
|
||||
stack2 = ((stack1 = depth0.description),typeof stack1 === functionType ? stack1.apply(depth0) : stack1);
|
||||
if(stack2 || stack2 === 0) { buffer += stack2; }
|
||||
buffer += "'>"
|
||||
+ escapeExpression(((stack1 = depth0.scope),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
||||
+ "</div>\n ";
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function program8(depth0,data) {
|
||||
|
||||
|
||||
return "</div>";
|
||||
}
|
||||
|
||||
function program10(depth0,data) {
|
||||
|
||||
|
||||
return "\n <div class='access'>\n <span class=\"api-ic ic-off\" title=\"click to authenticate\"></span>\n </div>\n ";
|
||||
}
|
||||
|
||||
function program12(depth0,data) {
|
||||
|
||||
|
||||
return "\n <h4>Response Class</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"response-content-type\" />\n ";
|
||||
}
|
||||
|
||||
function program14(depth0,data) {
|
||||
|
||||
|
||||
return "\n <h4>Parameters</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th style=\"width: 100px; max-width: 100px\">Parameter</th>\n <th style=\"width: 310px; max-width: 310px\">Value</th>\n <th style=\"width: 200px; max-width: 200px\">Description</th>\n <th style=\"width: 100px; max-width: 100px\">Parameter Type</th>\n <th style=\"width: 220px; max-width: 230px\">Data Type</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n ";
|
||||
}
|
||||
|
||||
function program7(depth0,data) {
|
||||
function program16(depth0,data) {
|
||||
|
||||
|
||||
return "\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Error Status Codes</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n ";
|
||||
return "\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Response Messages</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n <th>Response Model</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n ";
|
||||
}
|
||||
|
||||
function program9(depth0,data) {
|
||||
function program18(depth0,data) {
|
||||
|
||||
|
||||
return "\n ";
|
||||
}
|
||||
|
||||
function program11(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 ";
|
||||
@@ -418,16 +459,37 @@ function program11(depth0,data) {
|
||||
stack1 = helpers['if'].call(depth0, depth0.notes, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.type, {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
|
||||
options = {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data};
|
||||
if (stack1 = helpers.oauth) { stack1 = stack1.call(depth0, options); }
|
||||
else { stack1 = depth0.oauth; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
stack1 = helpers.each.call(depth0, depth0.oauth, {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
options = {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data};
|
||||
if (stack1 = helpers.oauth) { stack1 = stack1.call(depth0, options); }
|
||||
else { stack1 = depth0.oauth; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
options = {hash:{},inverse:self.noop,fn:self.program(10, program10, data),data:data};
|
||||
if (stack1 = helpers.oauth) { stack1 = stack1.call(depth0, options); }
|
||||
else { stack1 = depth0.oauth; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.type, {hash:{},inverse:self.noop,fn:self.program(12, program12, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.parameters, {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
|
||||
stack1 = helpers['if'].call(depth0, depth0.parameters, {hash:{},inverse:self.noop,fn:self.program(14, program14, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.responseMessages, {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data});
|
||||
stack1 = helpers['if'].call(depth0, depth0.responseMessages, {hash:{},inverse:self.noop,fn:self.program(16, program16, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.isReadOnly, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data});
|
||||
stack1 = helpers['if'].call(depth0, depth0.isReadOnly, {hash:{},inverse:self.program(20, program20, data),fn:self.program(18, program18, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";
|
||||
return buffer;
|
||||
@@ -500,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;
|
||||
@@ -508,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)
|
||||
@@ -516,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;
|
||||
}
|
||||
|
||||
@@ -1140,7 +1211,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.message; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "</td>\n";
|
||||
buffer += "</td>\n<td width='50%'><span class=\"model-signature\" /></td>";
|
||||
return buffer;
|
||||
});
|
||||
})();
|
||||
@@ -1227,7 +1298,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
|
||||
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) {
|
||||
@@ -1360,6 +1432,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
MainView = (function(_super) {
|
||||
var sorters;
|
||||
|
||||
__extends(MainView, _super);
|
||||
|
||||
function MainView() {
|
||||
@@ -1367,7 +1441,33 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
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, _ref3;
|
||||
@@ -1469,17 +1569,72 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
'submit .sandbox': 'submitOperation',
|
||||
'click .submit': 'submitOperation',
|
||||
'click .response_hider': 'hideResponse',
|
||||
'click .toggleOperation': 'toggleOperationContent'
|
||||
'click .toggleOperation': 'toggleOperationContent',
|
||||
'mouseenter .api-ic': 'mouseEnter',
|
||||
'mouseout .api-ic': 'mouseExit'
|
||||
};
|
||||
|
||||
OperationView.prototype.initialize = function() {};
|
||||
|
||||
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 = e.pageX;
|
||||
y = e.pageY;
|
||||
scX = $(window).scrollLeft();
|
||||
scY = $(window).scrollTop();
|
||||
scMaxX = scX + $(window).width();
|
||||
scMaxY = scY + $(window).height();
|
||||
wd = elem.width();
|
||||
hgh = elem.height();
|
||||
if (x + wd > scMaxX) {
|
||||
x = scMaxX - wd;
|
||||
}
|
||||
if (x < scX) {
|
||||
x = scX;
|
||||
}
|
||||
if (y + hgh > scMaxY) {
|
||||
y = scMaxY - hgh;
|
||||
}
|
||||
if (y < scY) {
|
||||
y = scY;
|
||||
}
|
||||
pos = {};
|
||||
pos.top = y;
|
||||
pos.left = x;
|
||||
elem.css(pos);
|
||||
return $(e.currentTarget.parentNode).find('#api_information_panel').show();
|
||||
};
|
||||
|
||||
OperationView.prototype.mouseExit = function(e) {
|
||||
return $(e.currentTarget.parentNode).find('#api_information_panel').hide();
|
||||
};
|
||||
|
||||
OperationView.prototype.render = function() {
|
||||
var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7;
|
||||
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) {
|
||||
_ref5 = this.model.authorizations;
|
||||
for (k in _ref5) {
|
||||
v = _ref5[k];
|
||||
if (k === "oauth2") {
|
||||
if (this.model.oauth === null) {
|
||||
this.model.oauth = {};
|
||||
}
|
||||
if (this.model.oauth.scopes === void 0) {
|
||||
this.model.oauth.scopes = [];
|
||||
}
|
||||
for (_i = 0, _len = v.length; _i < _len; _i++) {
|
||||
o = v[_i];
|
||||
this.model.oauth.scopes.push(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$(this.el).html(Handlebars.templates.operation(this.model));
|
||||
if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') {
|
||||
signatureModel = {
|
||||
@@ -1500,9 +1655,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
contentTypeModel.consumes = this.model.consumes;
|
||||
contentTypeModel.produces = this.model.produces;
|
||||
_ref5 = this.model.parameters;
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
param = _ref5[_i];
|
||||
_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) {
|
||||
@@ -1515,14 +1670,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
model: contentTypeModel
|
||||
});
|
||||
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
|
||||
_ref6 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
param = _ref6[_j];
|
||||
_ref7 = this.model.parameters;
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
param = _ref7[_k];
|
||||
this.addParameter(param, contentTypeModel.consumes);
|
||||
}
|
||||
_ref7 = this.model.responseMessages;
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
statusCode = _ref7[_k];
|
||||
_ref8 = this.model.responseMessages;
|
||||
for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
|
||||
statusCode = _ref8[_l];
|
||||
this.addStatusCode(statusCode);
|
||||
}
|
||||
return this;
|
||||
@@ -1615,9 +1770,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
OperationView.prototype.handleFileUpload = function(map, form) {
|
||||
var bodyParam, el, headerParams, o, obj, param, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8,
|
||||
var bodyParam, el, headerParams, o, obj, param, params, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8,
|
||||
_this = this;
|
||||
log("it's a file upload");
|
||||
_ref5 = form.serializeArray();
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
o = _ref5[_i];
|
||||
@@ -1626,11 +1780,12 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
}
|
||||
}
|
||||
bodyParam = new FormData();
|
||||
params = 0;
|
||||
_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]);
|
||||
}
|
||||
}
|
||||
@@ -1647,9 +1802,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
_ref8 = form.find('input[type~="file"]');
|
||||
for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
|
||||
el = _ref8[_l];
|
||||
bodyParam.append($(el).attr('name'), el.files[0]);
|
||||
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>");
|
||||
obj = {
|
||||
@@ -1673,6 +1830,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
if (window.authorizations) {
|
||||
window.authorizations.apply(obj);
|
||||
}
|
||||
if (params === 0) {
|
||||
obj.data.append("fake", "true");
|
||||
}
|
||||
jQuery.ajax(obj);
|
||||
return false;
|
||||
};
|
||||
@@ -1847,7 +2007,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
$(".request_url", $(this.el)).html("<pre>" + url + "</pre>");
|
||||
$(".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();
|
||||
@@ -1879,9 +2039,23 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
StatusCodeView.prototype.initialize = function() {};
|
||||
|
||||
StatusCodeView.prototype.render = function() {
|
||||
var template;
|
||||
var responseModel, responseModelView, template;
|
||||
template = this.template();
|
||||
$(this.el).html(template(this.model));
|
||||
if (swaggerUi.api.models.hasOwnProperty(this.model.responseModel)) {
|
||||
responseModel = {
|
||||
sampleJSON: JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(), null, 2),
|
||||
isParam: false,
|
||||
signature: swaggerUi.api.models[this.model.responseModel].getMockSignature()
|
||||
};
|
||||
responseModelView = new SignatureView({
|
||||
model: responseModel,
|
||||
tagName: 'div'
|
||||
});
|
||||
$('.model-signature', this.$el).append(responseModelView.render().el);
|
||||
} else {
|
||||
$('.model-signature', this.$el).html('');
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -2002,7 +2176,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');
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
var pack = require('./package');
|
||||
var path = require('path');
|
||||
|
||||
module.exports = {
|
||||
version: pack.version,
|
||||
dist: path.resolve(__dirname, 'dist')
|
||||
};
|
||||
@@ -0,0 +1,211 @@
|
||||
var appName;
|
||||
var popupMask;
|
||||
var popupDialog;
|
||||
var clientId;
|
||||
var realm;
|
||||
|
||||
function handleLogin() {
|
||||
var scopes = [];
|
||||
|
||||
if(window.swaggerUi.api.authSchemes
|
||||
&& window.swaggerUi.api.authSchemes.oauth2
|
||||
&& window.swaggerUi.api.authSchemes.oauth2.scopes) {
|
||||
scopes = window.swaggerUi.api.authSchemes.oauth2.scopes;
|
||||
}
|
||||
|
||||
if(window.swaggerUi.api
|
||||
&& window.swaggerUi.api.info) {
|
||||
appName = window.swaggerUi.api.info.title;
|
||||
}
|
||||
|
||||
if(popupDialog.length > 0)
|
||||
popupDialog = popupDialog.last();
|
||||
else {
|
||||
popupDialog = $(
|
||||
[
|
||||
'<div class="api-popup-dialog">',
|
||||
'<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
|
||||
'<div class="api-popup-content">',
|
||||
'<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.',
|
||||
'<a href="#">Learn how to use</a>',
|
||||
'</p>',
|
||||
'<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
|
||||
'<ul class="api-popup-scopes">',
|
||||
'</ul>',
|
||||
'<p class="error-msg"></p>',
|
||||
'<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
|
||||
'</div>',
|
||||
'</div>'].join(''));
|
||||
$(document.body).append(popupDialog);
|
||||
|
||||
popup = popupDialog.find('ul.api-popup-scopes').empty();
|
||||
for (i = 0; i < scopes.length; i ++) {
|
||||
scope = scopes[i];
|
||||
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
|
||||
if (scope.description) {
|
||||
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
|
||||
}
|
||||
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;
|
||||
|
||||
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();
|
||||
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var host = window.location;
|
||||
var redirectUrl = host.protocol + '//' + host.host + "/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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var scopes = []
|
||||
var o = $('.api-popup-scopes').find('input:checked');
|
||||
|
||||
for(k =0; k < o.length; k++) {
|
||||
scopes.push($(o[k]).attr("scope"));
|
||||
}
|
||||
|
||||
window.enabledScopes=scopes;
|
||||
|
||||
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
|
||||
url += '&realm=' + encodeURIComponent(realm);
|
||||
url += '&client_id=' + encodeURIComponent(clientId);
|
||||
url += '&scope=' + encodeURIComponent(scopes);
|
||||
|
||||
window.open(url);
|
||||
});
|
||||
|
||||
popupMask.show();
|
||||
popupDialog.show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
function handleLogout() {
|
||||
for(key in window.authorizations.authz){
|
||||
window.authorizations.remove(key)
|
||||
}
|
||||
window.enabledScopes = null;
|
||||
$('.api-ic.ic-on').addClass('ic-off');
|
||||
$('.api-ic.ic-on').removeClass('ic-on');
|
||||
|
||||
// set the info box
|
||||
$('.api-ic.ic-warning').addClass('ic-error');
|
||||
$('.api-ic.ic-warning').removeClass('ic-warning');
|
||||
}
|
||||
|
||||
function initOAuth(opts) {
|
||||
var o = (opts||{});
|
||||
var errors = [];
|
||||
|
||||
appName = (o.appName||errors.push("missing appName"));
|
||||
popupMask = (o.popupMask||$('#api-common-mask'));
|
||||
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
|
||||
clientId = (o.clientId||errors.push("missing client id"));
|
||||
realm = (o.realm||errors.push("missing realm"));
|
||||
|
||||
if(errors.length > 0){
|
||||
log("auth unable initialize oauth: " + errors);
|
||||
return;
|
||||
}
|
||||
|
||||
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
|
||||
$('.api-ic').click(function(s) {
|
||||
if($(s.target).hasClass('ic-off'))
|
||||
handleLogin();
|
||||
else {
|
||||
handleLogout();
|
||||
}
|
||||
false;
|
||||
});
|
||||
}
|
||||
|
||||
function onOAuthComplete(token) {
|
||||
if(token) {
|
||||
if(token.error) {
|
||||
var checkbox = $('input[type=checkbox],.secured')
|
||||
checkbox.each(function(pos){
|
||||
checkbox[pos].checked = false;
|
||||
});
|
||||
alert(token.error);
|
||||
}
|
||||
else {
|
||||
var b = token[window.swaggerUi.tokenName];
|
||||
if(b){
|
||||
// if all roles are satisfied
|
||||
var o = null;
|
||||
$.each($('.auth #api_information_panel'), function(k, v) {
|
||||
var children = v;
|
||||
if(children && children.childNodes) {
|
||||
var requiredScopes = [];
|
||||
$.each((children.childNodes), function (k1, v1){
|
||||
var inner = v1.innerHTML;
|
||||
if(inner)
|
||||
requiredScopes.push(inner);
|
||||
});
|
||||
var diff = [];
|
||||
for(var i=0; i < requiredScopes.length; i++) {
|
||||
var s = requiredScopes[i];
|
||||
if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) {
|
||||
diff.push(s);
|
||||
}
|
||||
}
|
||||
if(diff.length > 0){
|
||||
o = v.parentNode;
|
||||
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
|
||||
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
|
||||
|
||||
// sorry, not all scopes are satisfied
|
||||
$(o).find('.api-ic').addClass('ic-warning');
|
||||
$(o).find('.api-ic').removeClass('ic-error');
|
||||
}
|
||||
else {
|
||||
o = v.parentNode;
|
||||
$(o.parentNode).find('.api-ic.ic-off').addClass('ic-on');
|
||||
$(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');
|
||||
|
||||
// all scopes are satisfied
|
||||
$(o).find('.api-ic').addClass('ic-info');
|
||||
$(o).find('.api-ic').removeClass('ic-warning');
|
||||
$(o).find('.api-ic').removeClass('ic-error');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.authorizations.add("oauth2", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+324
-121
@@ -1,5 +1,5 @@
|
||||
// swagger.js
|
||||
// version 2.0.26
|
||||
// version 2.0.34
|
||||
|
||||
var __bind = function(fn, me){
|
||||
return function(){
|
||||
@@ -11,7 +11,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] );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,13 +25,13 @@ if (!Array.prototype.indexOf) {
|
||||
}
|
||||
|
||||
if (!('filter' in Array.prototype)) {
|
||||
Array.prototype.filter= function(filter, that /*opt*/) {
|
||||
var other= [], v;
|
||||
for (var i=0, n= this.length; i<n; i++)
|
||||
if (i in this && filter.call(that, v= this[i], i, this))
|
||||
other.push(v);
|
||||
return other;
|
||||
};
|
||||
Array.prototype.filter= function(filter, that /*opt*/) {
|
||||
var other= [], v;
|
||||
for (var i=0, n= this.length; i<n; i++)
|
||||
if (i in this && filter.call(that, v= this[i], i, this))
|
||||
other.push(v);
|
||||
return other;
|
||||
};
|
||||
}
|
||||
|
||||
if (!('map' in Array.prototype)) {
|
||||
@@ -57,24 +57,24 @@ Object.keys = Object.keys || (function () {
|
||||
'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;
|
||||
};
|
||||
})();
|
||||
@@ -87,6 +87,7 @@ var SwaggerApi = function(url, options) {
|
||||
this.authorizations = null;
|
||||
this.authorizationScheme = null;
|
||||
this.info = null;
|
||||
this.useJQuery = false;
|
||||
|
||||
options = (options||{});
|
||||
if (url)
|
||||
@@ -103,6 +104,9 @@ 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)
|
||||
@@ -368,22 +372,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 +488,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, '');
|
||||
@@ -562,15 +571,20 @@ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
|
||||
};
|
||||
|
||||
SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
|
||||
var result = {};
|
||||
var modelsToIgnore = (modelsToIgnore||[])
|
||||
modelsToIgnore.push(this.name);
|
||||
for (var i = 0; i < this.properties.length; i++) {
|
||||
prop = this.properties[i];
|
||||
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
||||
if(sampleModels[this.name]) {
|
||||
return sampleModels[this.name];
|
||||
}
|
||||
else {
|
||||
var result = {};
|
||||
var modelsToIgnore = (modelsToIgnore||[])
|
||||
modelsToIgnore.push(this.name);
|
||||
for (var i = 0; i < this.properties.length; i++) {
|
||||
prop = this.properties[i];
|
||||
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
||||
}
|
||||
modelsToIgnore.pop(this.name);
|
||||
return result;
|
||||
}
|
||||
modelsToIgnore.pop(this.name);
|
||||
return result;
|
||||
};
|
||||
|
||||
var SwaggerModelProperty = function(name, obj) {
|
||||
@@ -793,7 +807,22 @@ SwaggerOperation.prototype.getSampleJSON = function(type, models) {
|
||||
val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
|
||||
if (val) {
|
||||
val = listType ? [val] : val;
|
||||
return JSON.stringify(val, null, 2);
|
||||
if(typeof val == "string")
|
||||
return val;
|
||||
else if(typeof val === "object") {
|
||||
var t = val;
|
||||
if(val instanceof Array && val.length > 0) {
|
||||
t = val[0];
|
||||
}
|
||||
if(t.nodeName) {
|
||||
var xmlString = new XMLSerializer().serializeToString(t);
|
||||
return this.formatXml(xmlString);
|
||||
}
|
||||
else
|
||||
return JSON.stringify(val, null, 2);
|
||||
}
|
||||
else
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -882,6 +911,22 @@ SwaggerOperation.prototype.pathXml = function() {
|
||||
return this.path.replace("{format}", "xml");
|
||||
};
|
||||
|
||||
SwaggerOperation.prototype.encodePathParam = function(pathParam) {
|
||||
var encParts, part, parts, _i, _len;
|
||||
pathParam = pathParam.toString();
|
||||
if (pathParam.indexOf("/") === -1) {
|
||||
return encodeURIComponent(pathParam);
|
||||
} else {
|
||||
parts = pathParam.split("/");
|
||||
encParts = [];
|
||||
for (_i = 0, _len = parts.length; _i < _len; _i++) {
|
||||
part = parts[_i];
|
||||
encParts.push(encodeURIComponent(part));
|
||||
}
|
||||
return encParts.join("/");
|
||||
}
|
||||
};
|
||||
|
||||
SwaggerOperation.prototype.urlify = function(args) {
|
||||
var url = this.resource.basePath + this.pathJson();
|
||||
var params = this.parameters;
|
||||
@@ -891,7 +936,7 @@ SwaggerOperation.prototype.urlify = function(args) {
|
||||
if(args[param.name]) {
|
||||
// apply path params and remove from args
|
||||
var reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
|
||||
url = url.replace(reg, encodeURIComponent(args[param.name]));
|
||||
url = url.replace(reg, this.encodePathParam(args[param.name]));
|
||||
delete args[param.name];
|
||||
}
|
||||
else
|
||||
@@ -960,10 +1005,84 @@ SwaggerOperation.prototype.help = function() {
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
SwaggerOperation.prototype.formatXml = function(xml) {
|
||||
var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
|
||||
reg = /(>)(<)(\/*)/g;
|
||||
wsexp = /[ ]*(.*)[ ]+\n/g;
|
||||
contexp = /(<.+>)(.+\n)/g;
|
||||
xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
|
||||
pad = 0;
|
||||
formatted = '';
|
||||
lines = xml.split('\n');
|
||||
indent = 0;
|
||||
lastType = 'other';
|
||||
transitions = {
|
||||
'single->single': 0,
|
||||
'single->closing': -1,
|
||||
'single->opening': 0,
|
||||
'single->other': 0,
|
||||
'closing->single': 0,
|
||||
'closing->closing': -1,
|
||||
'closing->opening': 0,
|
||||
'closing->other': 0,
|
||||
'opening->single': 1,
|
||||
'opening->closing': 0,
|
||||
'opening->opening': 1,
|
||||
'opening->other': 1,
|
||||
'other->single': 0,
|
||||
'other->closing': -1,
|
||||
'other->opening': 0,
|
||||
'other->other': 0
|
||||
};
|
||||
_fn = function(ln) {
|
||||
var fromTo, j, key, padding, type, types, value;
|
||||
types = {
|
||||
single: Boolean(ln.match(/<.+\/>/)),
|
||||
closing: Boolean(ln.match(/<\/.+>/)),
|
||||
opening: Boolean(ln.match(/<[^!?].*>/))
|
||||
};
|
||||
type = ((function() {
|
||||
var _results;
|
||||
_results = [];
|
||||
for (key in types) {
|
||||
value = types[key];
|
||||
if (value) {
|
||||
_results.push(key);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
})())[0];
|
||||
type = type === void 0 ? 'other' : type;
|
||||
fromTo = lastType + '->' + type;
|
||||
lastType = type;
|
||||
padding = '';
|
||||
indent += transitions[fromTo];
|
||||
padding = ((function() {
|
||||
var _j, _ref5, _results;
|
||||
_results = [];
|
||||
for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
|
||||
_results.push(' ');
|
||||
}
|
||||
return _results;
|
||||
})()).join('');
|
||||
if (fromTo === 'opening->closing') {
|
||||
return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
|
||||
} else {
|
||||
return formatted += padding + ln + '\n';
|
||||
}
|
||||
};
|
||||
for (_i = 0, _len = lines.length; _i < _len; _i++) {
|
||||
ln = lines[_i];
|
||||
_fn(ln);
|
||||
}
|
||||
return formatted;
|
||||
};
|
||||
|
||||
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;
|
||||
@@ -980,62 +1099,12 @@ 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) {
|
||||
// encode the body for form submits
|
||||
if (headers["Accept"] && headers["Accept"].indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
var fields = {};
|
||||
var possibleParams = {};
|
||||
var values = {};
|
||||
@@ -1057,19 +1126,12 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
||||
}
|
||||
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: {
|
||||
@@ -1106,6 +1168,99 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
||||
}
|
||||
};
|
||||
|
||||
SwaggerRequest.prototype.setHeaders = function(params, operation) {
|
||||
// default type
|
||||
var accepts = "application/json";
|
||||
var contentType = null;
|
||||
|
||||
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)
|
||||
accepts = this.opts.requestContentType;
|
||||
} else {
|
||||
// if any form params, content type must be set
|
||||
if(definedFormParams.length > 0) {
|
||||
if(definedFileParams.length > 0)
|
||||
accepts = "multipart/form-data";
|
||||
else
|
||||
accepts = "application/x-www-form-urlencoded";
|
||||
}
|
||||
else if (this.type == "DELETE")
|
||||
body = "{}";
|
||||
else if (this.type != "DELETE")
|
||||
accepts = null;
|
||||
}
|
||||
|
||||
if (contentType && this.operation.consumes) {
|
||||
if (this.operation.consumes.indexOf(contentType) === -1) {
|
||||
log("server doesn't consume " + contentType + ", try " + JSON.stringify(this.operation.consumes));
|
||||
contentType = 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 (contentType && contentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
var fields = {};
|
||||
var possibleParams = {};
|
||||
var values = {};
|
||||
var key;
|
||||
for(key in formParams){
|
||||
var param = formParams[key];
|
||||
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);
|
||||
}
|
||||
}
|
||||
body = encoded;
|
||||
}
|
||||
if ((contentType && body !== "") || (contentType === "application/x-www-form-urlencoded"))
|
||||
headers["Content-Type"] = contentType;
|
||||
if (accepts)
|
||||
headers["Accept"] = accepts;
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
SwaggerRequest.prototype.asCurl = function() {
|
||||
var results = [];
|
||||
if(this.headers) {
|
||||
@@ -1149,9 +1304,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;
|
||||
@@ -1180,14 +1342,25 @@ JQueryHttpClient.prototype.execute = function(obj) {
|
||||
|
||||
obj.data = obj.body;
|
||||
obj.complete = function(response, textStatus, opts) {
|
||||
headers = {};
|
||||
headerArray = response.getAllResponseHeaders().split(":");
|
||||
var headers = {},
|
||||
headerArray = response.getAllResponseHeaders().split("\n");
|
||||
|
||||
for(var i = 0; i < headerArray.length / 2; i++)
|
||||
headers[headerArray[i] = headerArray[i+1]];
|
||||
for(var i = 0; i < headerArray.length; i++) {
|
||||
var toSplit = headerArray[i].trim();
|
||||
if(toSplit.length === 0)
|
||||
continue;
|
||||
var separator = toSplit.indexOf(":");
|
||||
if(separator === -1) {
|
||||
// Name but no value in the header
|
||||
headers[toSplit] = null;
|
||||
continue;
|
||||
}
|
||||
var name = toSplit.substring(0, separator).trim(),
|
||||
value = toSplit.substring(separator + 1).trim();
|
||||
headers[name] = value;
|
||||
}
|
||||
|
||||
out = {
|
||||
headers: headers,
|
||||
var out = {
|
||||
url: request.url,
|
||||
method: request.method,
|
||||
status: response.status,
|
||||
@@ -1214,8 +1387,8 @@ JQueryHttpClient.prototype.execute = function(obj) {
|
||||
return cb.response(out);
|
||||
};
|
||||
|
||||
$.support.cors = true;
|
||||
return $.ajax(obj);
|
||||
jQuery.support.cors = true;
|
||||
return jQuery.ajax(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1331,16 +1504,31 @@ 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;
|
||||
};
|
||||
|
||||
@@ -1366,6 +1554,16 @@ ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
}
|
||||
};
|
||||
|
||||
var CookieAuthorization = function(cookie) {
|
||||
this.cookie = cookie;
|
||||
}
|
||||
|
||||
CookieAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
obj.cookieJar = obj.cookieJar || CookieJar();
|
||||
obj.cookieJar.setCookie(this.cookie);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Password Authorization is a basic auth implementation
|
||||
*/
|
||||
@@ -1388,11 +1586,16 @@ PasswordAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
|
||||
var e = (typeof window !== 'undefined' ? window : exports);
|
||||
|
||||
var sampleModels = {};
|
||||
var cookies = {};
|
||||
|
||||
e.SampleModels = sampleModels;
|
||||
e.SwaggerHttp = SwaggerHttp;
|
||||
e.SwaggerRequest = SwaggerRequest;
|
||||
e.authorizations = new SwaggerAuthorizations();
|
||||
e.ApiKeyAuthorization = ApiKeyAuthorization;
|
||||
e.PasswordAuthorization = PasswordAuthorization;
|
||||
e.CookieAuthorization = CookieAuthorization;
|
||||
e.JQueryHttpClient = JQueryHttpClient;
|
||||
e.ShredHttpClient = ShredHttpClient;
|
||||
e.SwaggerOperation = SwaggerOperation;
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "swagger-ui",
|
||||
"version": "2.0.14",
|
||||
"version": "2.0.19",
|
||||
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
|
||||
"scripts": {
|
||||
"build": "PATH=$PATH:./node_modules/.bin cake dist",
|
||||
@@ -18,8 +18,8 @@
|
||||
"license": "Apache",
|
||||
"readmeFilename": "README.md",
|
||||
"dependencies": {
|
||||
"coffee-script": "~1.5.0",
|
||||
"swagger-client": "2.0.26",
|
||||
"coffee-script": "~1.6.3",
|
||||
"swagger-client": "2.0.34",
|
||||
"handlebars": "~1.0.10",
|
||||
"less": "~1.4.2"
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class SwaggerUi extends Backbone.Router
|
||||
# so it gets called when SwaggerApi completes loading
|
||||
render:() ->
|
||||
@showMessage('Finished Loading Resource Information. Rendering Swagger UI...')
|
||||
@mainView = new MainView({model: @api, el: $('#' + @dom_id)}).render()
|
||||
@mainView = new MainView({model: @api, el: $('#' + @dom_id), swaggerOptions: @options}).render()
|
||||
@showMessage()
|
||||
switch @options.docExpansion
|
||||
when "full" then Docs.expandOperationsForResource('')
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
class MainView extends Backbone.View
|
||||
initialize: ->
|
||||
sorters = {
|
||||
'alpha' : (a,b) -> return a.path.localeCompare(b.path),
|
||||
'method' : (a,b) -> return a.method.localeCompare(b.method),
|
||||
}
|
||||
|
||||
initialize: (opts={}) ->
|
||||
if opts.swaggerOptions.sorter
|
||||
sorterName = opts.swaggerOptions.sorter
|
||||
sorter = sorters[sorterName]
|
||||
for route in @model.apisArray
|
||||
route.operationsArray.sort sorter
|
||||
if (sorterName == "alpha") # sort top level paths if alpha
|
||||
@model.apisArray.sort sorter
|
||||
|
||||
render: ->
|
||||
# Render the outer container for resources
|
||||
$(@el).html(Handlebars.templates.main(@model))
|
||||
@@ -25,4 +37,4 @@ class MainView extends Backbone.View
|
||||
$('#resources').append resourceView.render().el
|
||||
|
||||
clear: ->
|
||||
$(@el).html ''
|
||||
$(@el).html ''
|
||||
|
||||
@@ -6,14 +6,55 @@ class OperationView extends Backbone.View
|
||||
'click .submit' : 'submitOperation'
|
||||
'click .response_hider' : 'hideResponse'
|
||||
'click .toggleOperation' : 'toggleOperationContent'
|
||||
'mouseenter .api-ic' : 'mouseEnter'
|
||||
'mouseout .api-ic' : 'mouseExit'
|
||||
}
|
||||
|
||||
initialize: ->
|
||||
|
||||
mouseEnter: (e) ->
|
||||
elem = $(e.currentTarget.parentNode).find('#api_information_panel')
|
||||
x = e.pageX
|
||||
y = e.pageY
|
||||
scX = $(window).scrollLeft()
|
||||
scY = $(window).scrollTop()
|
||||
scMaxX = scX + $(window).width()
|
||||
scMaxY = scY + $(window).height()
|
||||
wd = elem.width()
|
||||
hgh = elem.height()
|
||||
|
||||
if (x + wd > scMaxX)
|
||||
x = scMaxX - wd
|
||||
if (x < scX)
|
||||
x = scX
|
||||
if (y + hgh > scMaxY)
|
||||
y = scMaxY - hgh
|
||||
if (y < scY)
|
||||
y = scY
|
||||
pos = {}
|
||||
pos.top = y
|
||||
pos.left = x
|
||||
elem.css(pos)
|
||||
$(e.currentTarget.parentNode).find('#api_information_panel').show()
|
||||
|
||||
mouseExit: (e) ->
|
||||
$(e.currentTarget.parentNode).find('#api_information_panel').hide()
|
||||
|
||||
render: ->
|
||||
isMethodSubmissionSupported = true #jQuery.inArray(@model.method, @model.supportedSubmitMethods) >= 0
|
||||
@model.isReadOnly = true unless isMethodSubmissionSupported
|
||||
|
||||
@model.oauth = null
|
||||
if @model.authorizations
|
||||
for k, v of @model.authorizations
|
||||
if k == "oauth2"
|
||||
if @model.oauth == null
|
||||
@model.oauth = {}
|
||||
if @model.oauth.scopes is undefined
|
||||
@model.oauth.scopes = []
|
||||
for o in v
|
||||
@model.oauth.scopes.push o
|
||||
|
||||
$(@el).html(Handlebars.templates.operation(@model))
|
||||
|
||||
if @model.responseClassSignature and @model.responseClassSignature != 'string'
|
||||
@@ -110,18 +151,18 @@ class OperationView extends Backbone.View
|
||||
parent.showCompleteStatus response
|
||||
|
||||
handleFileUpload: (map, form) ->
|
||||
log "it's a file upload"
|
||||
for o in form.serializeArray()
|
||||
if(o.value? && jQuery.trim(o.value).length > 0)
|
||||
map[o.name] = o.value
|
||||
|
||||
# requires HTML5 compatible browser
|
||||
bodyParam = new FormData()
|
||||
params = 0
|
||||
|
||||
# add params
|
||||
for param in @model.parameters
|
||||
if param.paramType is 'form'
|
||||
if map[param.name] != undefined
|
||||
if param.type.toLowerCase() isnt 'file' and map[param.name] != undefined
|
||||
bodyParam.append(param.name, map[param.name])
|
||||
|
||||
# headers in operation
|
||||
@@ -134,9 +175,9 @@ class OperationView extends Backbone.View
|
||||
|
||||
# add files
|
||||
for el in form.find('input[type~="file"]')
|
||||
bodyParam.append($(el).attr('name'), el.files[0])
|
||||
|
||||
log(bodyParam)
|
||||
if typeof el.files[0] isnt 'undefined'
|
||||
bodyParam.append($(el).attr('name'), el.files[0])
|
||||
params += 1
|
||||
|
||||
@invocationUrl =
|
||||
if @model.supportHeaderParams()
|
||||
@@ -166,6 +207,9 @@ class OperationView extends Backbone.View
|
||||
if window.authorizations
|
||||
window.authorizations.apply obj
|
||||
|
||||
if params is 0
|
||||
obj.data.append("fake", "true");
|
||||
|
||||
jQuery.ajax(obj)
|
||||
false
|
||||
# end of file-upload nastiness
|
||||
@@ -282,11 +326,11 @@ class OperationView extends Backbone.View
|
||||
# puts the response data in UI
|
||||
showStatus: (response) ->
|
||||
if response.content is undefined
|
||||
content = response.data
|
||||
url = response.url
|
||||
content = response.data
|
||||
url = response.url
|
||||
else
|
||||
content = response.content.data
|
||||
url = response.request.url
|
||||
content = response.content.data
|
||||
url = response.request.url
|
||||
headers = response.headers
|
||||
|
||||
# if server is nice, and sends content-type back, we can use it
|
||||
@@ -315,7 +359,7 @@ class OperationView extends Backbone.View
|
||||
$(".request_url", $(@el)).html "<pre>" + url + "</pre>"
|
||||
$(".response_code", $(@el)).html "<pre>" + response.status + "</pre>"
|
||||
$(".response_body", $(@el)).html response_body
|
||||
$(".response_headers", $(@el)).html "<pre>" + JSON.stringify(response.headers, null, " ").replace(/\n/g, "<br>") + "</pre>"
|
||||
$(".response_headers", $(@el)).html "<pre>" + _.escape(JSON.stringify(response.headers, null, " ")).replace(/\n/g, "<br>") + "</pre>"
|
||||
$(".response", $(@el)).slideDown()
|
||||
$(".response_hider", $(@el)).show()
|
||||
$(".response_throbber", $(@el)).hide()
|
||||
|
||||
@@ -11,7 +11,7 @@ class SignatureView extends Backbone.View
|
||||
template = @template()
|
||||
$(@el).html(template(@model))
|
||||
|
||||
@switchToDescription()
|
||||
@switchToSnippet()
|
||||
|
||||
@isParam = @model.isParam
|
||||
|
||||
|
||||
@@ -4,6 +4,17 @@ class StatusCodeView extends Backbone.View
|
||||
render: ->
|
||||
template = @template()
|
||||
$(@el).html(template(@model))
|
||||
|
||||
if swaggerUi.api.models.hasOwnProperty @model.responseModel
|
||||
responseModel =
|
||||
sampleJSON: JSON.stringify(swaggerUi.api.models[@model.responseModel].createJSONSample(), null, 2)
|
||||
isParam: false
|
||||
signature: swaggerUi.api.models[@model.responseModel].getMockSignature()
|
||||
|
||||
responseModelView = new SignatureView({model: responseModel, tagName: 'div'})
|
||||
$('.model-signature', @$el).append responseModelView.render().el
|
||||
else
|
||||
$('.model-signature', @$el).html ''
|
||||
@
|
||||
|
||||
template: ->
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
|
||||
Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
|
||||
|
||||
*/
|
||||
|
||||
pre code {
|
||||
display: block; padding: 0.5em;
|
||||
background: #F0F0F0;
|
||||
}
|
||||
|
||||
pre code,
|
||||
pre .subst,
|
||||
pre .tag .title,
|
||||
pre .lisp .title,
|
||||
pre .clojure .built_in,
|
||||
pre .nginx .title {
|
||||
color: black;
|
||||
}
|
||||
|
||||
pre .string,
|
||||
pre .title,
|
||||
pre .constant,
|
||||
pre .parent,
|
||||
pre .tag .value,
|
||||
pre .rules .value,
|
||||
pre .rules .value .number,
|
||||
pre .preprocessor,
|
||||
pre .ruby .symbol,
|
||||
pre .ruby .symbol .string,
|
||||
pre .aggregate,
|
||||
pre .template_tag,
|
||||
pre .django .variable,
|
||||
pre .smalltalk .class,
|
||||
pre .addition,
|
||||
pre .flow,
|
||||
pre .stream,
|
||||
pre .bash .variable,
|
||||
pre .apache .tag,
|
||||
pre .apache .cbracket,
|
||||
pre .tex .command,
|
||||
pre .tex .special,
|
||||
pre .erlang_repl .function_or_atom,
|
||||
pre .markdown .header {
|
||||
color: #800;
|
||||
}
|
||||
|
||||
pre .comment,
|
||||
pre .annotation,
|
||||
pre .template_comment,
|
||||
pre .diff .header,
|
||||
pre .chunk,
|
||||
pre .markdown .blockquote {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
pre .number,
|
||||
pre .date,
|
||||
pre .regexp,
|
||||
pre .literal,
|
||||
pre .smalltalk .symbol,
|
||||
pre .smalltalk .char,
|
||||
pre .go .constant,
|
||||
pre .change,
|
||||
pre .markdown .bullet,
|
||||
pre .markdown .link_url {
|
||||
color: #080;
|
||||
}
|
||||
|
||||
pre .label,
|
||||
pre .javadoc,
|
||||
pre .ruby .string,
|
||||
pre .decorator,
|
||||
pre .filter .argument,
|
||||
pre .localvars,
|
||||
pre .array,
|
||||
pre .attr_selector,
|
||||
pre .important,
|
||||
pre .pseudo,
|
||||
pre .pi,
|
||||
pre .doctype,
|
||||
pre .deletion,
|
||||
pre .envvar,
|
||||
pre .shebang,
|
||||
pre .apache .sqbracket,
|
||||
pre .nginx .built_in,
|
||||
pre .tex .formula,
|
||||
pre .erlang_repl .reserved,
|
||||
pre .prompt,
|
||||
pre .markdown .link_label,
|
||||
pre .vhdl .attribute,
|
||||
pre .clojure .attribute,
|
||||
pre .coffeescript .property {
|
||||
color: #88F
|
||||
}
|
||||
|
||||
pre .keyword,
|
||||
pre .id,
|
||||
pre .phpdoc,
|
||||
pre .title,
|
||||
pre .built_in,
|
||||
pre .aggregate,
|
||||
pre .css .tag,
|
||||
pre .javadoctag,
|
||||
pre .phpdoc,
|
||||
pre .yardoctag,
|
||||
pre .smalltalk .class,
|
||||
pre .winutils,
|
||||
pre .bash .variable,
|
||||
pre .apache .tag,
|
||||
pre .go .typename,
|
||||
pre .tex .command,
|
||||
pre .markdown .strong,
|
||||
pre .request,
|
||||
pre .status {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
pre .markdown .emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
pre .nginx .built_in {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
pre .coffeescript .javascript,
|
||||
pre .javascript .xml,
|
||||
pre .tex .formula,
|
||||
pre .xml .javascript,
|
||||
pre .xml .vbscript,
|
||||
pre .xml .css,
|
||||
pre .xml .cdata {
|
||||
opacity: 0.5;
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
|
||||
html,
|
||||
body,
|
||||
div,
|
||||
span,
|
||||
applet,
|
||||
object,
|
||||
iframe,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
p,
|
||||
blockquote,
|
||||
pre,
|
||||
a,
|
||||
abbr,
|
||||
acronym,
|
||||
address,
|
||||
big,
|
||||
cite,
|
||||
code,
|
||||
del,
|
||||
dfn,
|
||||
em,
|
||||
img,
|
||||
ins,
|
||||
kbd,
|
||||
q,
|
||||
s,
|
||||
samp,
|
||||
small,
|
||||
strike,
|
||||
strong,
|
||||
sub,
|
||||
sup,
|
||||
tt,
|
||||
var,
|
||||
b,
|
||||
u,
|
||||
i,
|
||||
center,
|
||||
dl,
|
||||
dt,
|
||||
dd,
|
||||
ol,
|
||||
ul,
|
||||
li,
|
||||
fieldset,
|
||||
form,
|
||||
label,
|
||||
legend,
|
||||
table,
|
||||
caption,
|
||||
tbody,
|
||||
tfoot,
|
||||
thead,
|
||||
tr,
|
||||
th,
|
||||
td,
|
||||
article,
|
||||
aside,
|
||||
canvas,
|
||||
details,
|
||||
embed,
|
||||
figure,
|
||||
figcaption,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
menu,
|
||||
nav,
|
||||
output,
|
||||
ruby,
|
||||
section,
|
||||
summary,
|
||||
time,
|
||||
mark,
|
||||
audio,
|
||||
video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article,
|
||||
aside,
|
||||
details,
|
||||
figcaption,
|
||||
figure,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
menu,
|
||||
nav,
|
||||
section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol,
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote,
|
||||
q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before,
|
||||
blockquote:after,
|
||||
q:before,
|
||||
q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
+520
-394
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
+27
-17
@@ -2,9 +2,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Swagger UI</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
||||
<link href='css/highlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||
<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'/>
|
||||
<link href='css/screen.css' media='print' rel='stylesheet' type='text/css'/>
|
||||
<script type="text/javascript" src="lib/shred.bundle.js"></script>
|
||||
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
|
||||
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
|
||||
@@ -16,6 +18,10 @@
|
||||
<script src='lib/swagger.js' type='text/javascript'></script>
|
||||
<script src='swagger-ui.js' type='text/javascript'></script>
|
||||
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
||||
|
||||
<!-- enabling this will enable oauth2 implicit scope support -->
|
||||
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
window.swaggerUi = new SwaggerUi({
|
||||
@@ -23,13 +29,26 @@
|
||||
dom_id: "swagger-ui-container",
|
||||
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||
onComplete: function(swaggerApi, swaggerUi){
|
||||
log("Loaded SwaggerUI")
|
||||
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
|
||||
log("Loaded SwaggerUI");
|
||||
|
||||
if(typeof initOAuth == "function") {
|
||||
/*
|
||||
initOAuth({
|
||||
clientId: "your-client-id",
|
||||
realm: "your-realms",
|
||||
appName: "your-app-name"
|
||||
});
|
||||
*/
|
||||
}
|
||||
$('pre code').each(function(i, e) {
|
||||
hljs.highlightBlock(e)
|
||||
});
|
||||
},
|
||||
onFailure: function(data) {
|
||||
log("Unable to Load SwaggerUI");
|
||||
},
|
||||
docExpansion: "none"
|
||||
docExpansion: "none",
|
||||
sorter : "alpha"
|
||||
});
|
||||
|
||||
$('#input_apiKey').change(function() {
|
||||
@@ -42,15 +61,13 @@
|
||||
})
|
||||
window.swaggerUi.load();
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body class="swagger-section">
|
||||
<div id='header'>
|
||||
<div class="swagger-ui-wrap">
|
||||
<a id="logo" href="http://swagger.wordnik.com">swagger</a>
|
||||
|
||||
<form id='api_selector'>
|
||||
<div class='input icon-btn'>
|
||||
<img id="show-pet-store-icon" src="images/pet_store_api.png" title="Show Swagger Petstore Example Apis">
|
||||
@@ -65,14 +82,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="message-bar" class="swagger-ui-wrap">
|
||||
|
||||
</div>
|
||||
|
||||
<div id="swagger-ui-container" class="swagger-ui-wrap">
|
||||
|
||||
</div>
|
||||
|
||||
<div id="message-bar" class="swagger-ui-wrap"> </div>
|
||||
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<script>
|
||||
var qp = null;
|
||||
if(window.location.hash) {
|
||||
qp = location.hash.substring(1);
|
||||
}
|
||||
else {
|
||||
qp = location.search.substring(1);
|
||||
}
|
||||
qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
|
||||
function(key, value) {
|
||||
return key===""?value:decodeURIComponent(value) }
|
||||
):{}
|
||||
window.opener.onOAuthComplete(qp);
|
||||
window.close();
|
||||
</script>
|
||||
@@ -66,7 +66,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] );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
.swagger-section {
|
||||
|
||||
.title {
|
||||
font-style: bold;
|
||||
}
|
||||
|
||||
.secondary_form {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.main_image {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.oauth_body {
|
||||
margin-left: 100px;
|
||||
margin-right: 100px;
|
||||
}
|
||||
|
||||
.oauth_submit {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.api-popup-dialog {
|
||||
z-index: 10000;
|
||||
position: absolute;
|
||||
width: 500px;
|
||||
background: #FFF;
|
||||
padding: 20px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
display: none;
|
||||
font-size: 13px;
|
||||
color: #777;
|
||||
|
||||
.api-popup-title{
|
||||
font-size: 24px;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.api-popup-title{
|
||||
font-size: 24px;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
|
||||
p.error-msg {
|
||||
padding-left: 5px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
button.api-popup-authbtn {
|
||||
height: 30px;
|
||||
}
|
||||
button.api-popup-cancel {
|
||||
height: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
.api-popup-scopes {
|
||||
padding: 10px 20px;
|
||||
|
||||
li {
|
||||
padding: 5px 0;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.api-scope-desc {
|
||||
padding-left: 20px;
|
||||
font-style: italic;
|
||||
}
|
||||
li input {
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
}
|
||||
.api-popup-actions {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
/*
|
||||
/* Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org> */
|
||||
|
||||
Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
|
||||
|
||||
*/
|
||||
.swagger-section {
|
||||
|
||||
pre code {
|
||||
display: block; padding: 0.5em;
|
||||
@@ -133,3 +131,5 @@ pre .xml .css,
|
||||
pre .xml .cdata {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
|
||||
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
|
||||
@@ -1,5 +1,75 @@
|
||||
@import 'src/main/less/reset.less';
|
||||
@import 'src/main/less/highlight_default.less';
|
||||
@import 'src/main/less/specs.less';
|
||||
@import 'src/main/less/auth.less';
|
||||
|
||||
.swagger-section {
|
||||
|
||||
.access {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.auth {
|
||||
float: right;
|
||||
}
|
||||
|
||||
#api_information_panel {
|
||||
position: absolute;
|
||||
background: #FFF;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
display: none;
|
||||
font-size: 13px;
|
||||
max-width: 300px;
|
||||
line-height: 30px;
|
||||
color: black;
|
||||
padding: 5px;
|
||||
p {
|
||||
.api-msg-enabled {
|
||||
color: green;
|
||||
}
|
||||
.api-msg-disabled {
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.api-ic {
|
||||
height: 18px;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
background: url(../images/explorer_icons.png) no-repeat;
|
||||
}
|
||||
|
||||
.ic-info {
|
||||
background-position: 0 0;
|
||||
width: 18px;
|
||||
margin-top: -7px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.ic-warning {
|
||||
background-position: -60px 0;
|
||||
width: 18px;
|
||||
margin-top: -7px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.ic-error {
|
||||
background-position: -30px 0;
|
||||
width: 18px;
|
||||
margin-top: -7px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.ic-off {
|
||||
background-position: -90px 0;
|
||||
width: 58px;
|
||||
margin-top: -4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.ic-on {
|
||||
background-position: -160px 0;
|
||||
width: 58px;
|
||||
margin-top: -4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#header {
|
||||
background-color: #89bf04;
|
||||
@@ -64,4 +134,6 @@
|
||||
min-height: 30px;
|
||||
text-align: center;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
.swagger-section {
|
||||
|
||||
.swagger-ui-wrap {
|
||||
|
||||
line-height: 1;
|
||||
@@ -632,6 +634,11 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
ul.options {
|
||||
li.access {
|
||||
color: black;
|
||||
}
|
||||
}
|
||||
}
|
||||
div.content {
|
||||
border-top: none;
|
||||
@@ -1035,5 +1042,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,22 @@
|
||||
<h4>Implementation Notes</h4>
|
||||
<p>{{{notes}}}</p>
|
||||
{{/if}}
|
||||
{{#oauth}}
|
||||
<div class="auth">
|
||||
<span class="api-ic ic-error"></span>{{/oauth}}
|
||||
{{#each oauth}}
|
||||
<div id="api_information_panel" style="top: 526px; left: 776px; display: none;">
|
||||
{{#each this}}
|
||||
<div title='{{{this.description}}}'>{{this.scope}}</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/each}}
|
||||
{{#oauth}}</div>{{/oauth}}
|
||||
{{#oauth}}
|
||||
<div class='access'>
|
||||
<span class="api-ic ic-off" title="click to authenticate"></span>
|
||||
</div>
|
||||
{{/oauth}}
|
||||
{{#if type}}
|
||||
<h4>Response Class</h4>
|
||||
<p><span class="model-signature" /></p>
|
||||
@@ -48,12 +64,13 @@
|
||||
{{/if}}
|
||||
{{#if responseMessages}}
|
||||
<div style='margin:0;padding:0;display:inline'></div>
|
||||
<h4>Error Status Codes</h4>
|
||||
<h4>Response Messages</h4>
|
||||
<table class='fullwidth'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>HTTP Status Code</th>
|
||||
<th>Reason</th>
|
||||
<th>Response Model</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="operation-status">
|
||||
|
||||
@@ -15,10 +15,15 @@
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#if defaultValue}}
|
||||
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value='{{defaultValue}}'/>
|
||||
{{#if isFile}}
|
||||
<input type="file" name='{{name}}'/>
|
||||
<div class="parameter-content-type" />
|
||||
{{else}}
|
||||
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value=''/>
|
||||
{{#if defaultValue}}
|
||||
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value='{{defaultValue}}'/>
|
||||
{{else}}
|
||||
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value=''/>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
<td width='15%' class='code'>{{code}}</td>
|
||||
<td>{{{message}}}</td>
|
||||
<td width='50%'><span class="model-signature" /></td>
|
||||
Reference in New Issue
Block a user