Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65a5bc34eb | ||
|
|
cc49093471 | ||
|
|
b336076a19 | ||
|
|
b8943665a2 | ||
|
|
0c0ffc569f | ||
|
|
18ce470f12 | ||
|
|
53593b796e | ||
|
|
2378b176f5 | ||
|
|
7dd5142df2 | ||
|
|
6b400b22fe | ||
|
|
c22d94b940 | ||
|
|
e7b9525911 | ||
|
|
ede80844a5 | ||
|
|
eea0d72a85 | ||
|
|
15acb15af6 | ||
|
|
54d0a8ec09 | ||
|
|
105c516f5f | ||
|
|
542d4fe478 | ||
|
|
97e96ba3d9 | ||
|
|
73eaf9f564 | ||
|
|
fc0ccd4486 | ||
|
|
7f68c35742 | ||
|
|
dc1bc43a19 | ||
|
|
c32f6e836d | ||
|
|
34bd474bff | ||
|
|
4601f62702 | ||
|
|
2bddfb688a | ||
|
|
b7458010f1 | ||
|
|
49f480440b | ||
|
|
e4d01c57bf | ||
|
|
187517dfe3 | ||
|
|
846628f1f3 | ||
|
|
355380a5c4 | ||
|
|
6db63006a6 | ||
|
|
0505d6cadf | ||
|
|
fcb82bdac4 | ||
|
|
348f1e109b | ||
|
|
abc3600994 | ||
|
|
77882a0e3e | ||
|
|
0e98639f45 | ||
|
|
3347d7e9fd | ||
|
|
929f8b61f2 | ||
|
|
8158e9b25f | ||
|
|
a0db8582a1 | ||
|
|
1b662db2d2 | ||
|
|
cd4fa99cc4 | ||
|
|
bc93240199 | ||
|
|
999367589d | ||
|
|
8a9eedfdf3 | ||
|
|
046e534d03 | ||
|
|
73c89ba3f6 | ||
|
|
ff05f9113b | ||
|
|
6c1de0b560 | ||
|
|
4fb5b86db1 | ||
|
|
5f4eec1b8a | ||
|
|
f22efb66de |
@@ -1,6 +1,7 @@
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
{exec} = require 'child_process'
|
||||
less = require 'less'
|
||||
|
||||
sourceFiles = [
|
||||
'SwaggerUi'
|
||||
@@ -71,13 +72,25 @@ task 'dist', 'Build a distribution', ->
|
||||
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
|
||||
pack()
|
||||
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)
|
||||
pack()
|
||||
|
||||
pack = ->
|
||||
console.log ' : Packaging...'
|
||||
exec 'cp -r lib dist'
|
||||
console.log ' : Copied swagger-ui libs'
|
||||
exec 'cp -r node_modules/swagger-client/lib/swagger.js dist/lib'
|
||||
console.log ' : Copied swagger dependencies'
|
||||
exec 'cp -r src/main/html/* dist'
|
||||
console.log ' : Copied html dependencies'
|
||||
console.log ' !'
|
||||
|
||||
task 'spec', "Run the test suite", ->
|
||||
@@ -107,6 +120,7 @@ task 'watch', 'Watch source files for changes and autocompile', ->
|
||||
watchFiles("src/main/template")
|
||||
watchFiles("src/main/javascript")
|
||||
watchFiles("src/main/html")
|
||||
watchFiles("src/main/less")
|
||||
watchFiles("src/test")
|
||||
|
||||
notify = (message) ->
|
||||
@@ -115,4 +129,4 @@ notify = (message) ->
|
||||
# options =
|
||||
# title: 'CoffeeScript'
|
||||
# image: 'bin/CoffeeScript.png'
|
||||
# try require('growl') message, options
|
||||
# try require('growl') message, options
|
||||
|
||||
@@ -16,9 +16,10 @@ You can use the swagger-ui code AS-IS! No need to build or recompile--just clon
|
||||
You can rebuild swagger-ui on your own to tweak it or just so you can say you did. To do so, follow these steps:
|
||||
|
||||
1. install [handlebars](http://handlebarsjs.com/)
|
||||
2. npm install
|
||||
3. npm run-script build
|
||||
4. You should see the distribution under the dist folder. Open ./dist/index.html to launch Swagger UI in a browser
|
||||
2. install java
|
||||
3. npm install
|
||||
4. npm run-script build
|
||||
5. You should see the distribution under the dist folder. Open ./dist/index.html to launch Swagger UI in a browser
|
||||
|
||||
### Use
|
||||
Once you open the Swagger UI, it will load the [Swagger Petstore](http://petstore.swagger.wordnik.com/api/api-docs) service and show its APIs. You can enter your own server url and click explore to view the API.
|
||||
@@ -41,13 +42,13 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
|
||||
|
||||
```javascript
|
||||
window.swaggerUi = new SwaggerUi({
|
||||
discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs",
|
||||
url:"http://petstore.swagger.wordnik.com/api/api-docs",
|
||||
dom_id:"swagger-ui-container"
|
||||
});
|
||||
|
||||
window.swaggerUi.load();
|
||||
```
|
||||
* *discoveryUrl* parameter should point to a resource listing url as per [Swagger Spec](https://github.com/wordnik/swagger-core/wiki)
|
||||
* *url* parameter should point to a resource listing url as per [Swagger Spec](https://github.com/wordnik/swagger-core/wiki)
|
||||
* *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)
|
||||
@@ -91,6 +92,8 @@ Create your own fork of [wordnik/swagger-ui](https://github.com/wordnik/swagger-
|
||||
|
||||
To share your changes, [submit a pull request](https://github.com/wordnik/swagger-ui/pull/new/master).
|
||||
|
||||
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
|
||||
-------
|
||||
|
||||
|
||||
Vendored
+1043
-1755
File diff suppressed because it is too large
Load Diff
Vendored
+7
-13
@@ -2,10 +2,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Swagger UI</title>
|
||||
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
||||
<link href='css/hightlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||
<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='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||
<script type="text/javascript" src="lib/shred.bundle.js" /></script>
|
||||
<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>
|
||||
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
|
||||
@@ -16,7 +16,6 @@
|
||||
<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>
|
||||
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
window.swaggerUi = new SwaggerUi({
|
||||
@@ -24,25 +23,20 @@
|
||||
dom_id: "swagger-ui-container",
|
||||
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||
onComplete: function(swaggerApi, swaggerUi){
|
||||
if(console) {
|
||||
console.log("Loaded SwaggerUI")
|
||||
}
|
||||
log("Loaded SwaggerUI")
|
||||
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
|
||||
},
|
||||
onFailure: function(data) {
|
||||
if(console) {
|
||||
console.log("Unable to Load SwaggerUI");
|
||||
console.log(data);
|
||||
}
|
||||
log("Unable to Load SwaggerUI");
|
||||
},
|
||||
docExpansion: "none"
|
||||
});
|
||||
|
||||
$('#input_apiKey').change(function() {
|
||||
var key = $('#input_apiKey')[0].value;
|
||||
console.log("key: " + key);
|
||||
log("key: " + key);
|
||||
if(key && key.trim() != "") {
|
||||
console.log("added key " + key);
|
||||
log("added key " + key);
|
||||
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
|
||||
}
|
||||
})
|
||||
|
||||
Vendored
+1229
-1074
File diff suppressed because it is too large
Load Diff
Vendored
+261
-99
@@ -598,43 +598,64 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
function program1(depth0,data) {
|
||||
|
||||
|
||||
return "\n ";
|
||||
return " multiple='multiple'";
|
||||
}
|
||||
|
||||
function program3(depth0,data) {
|
||||
|
||||
|
||||
return "\n ";
|
||||
}
|
||||
|
||||
function program5(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data});
|
||||
stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(8, program8, data),fn:self.program(6, program6, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
return buffer;
|
||||
}
|
||||
function program4(depth0,data) {
|
||||
function program6(depth0,data) {
|
||||
|
||||
|
||||
return "\n ";
|
||||
}
|
||||
|
||||
function program6(depth0,data) {
|
||||
|
||||
|
||||
return "\n <option selected=\"\" value=''></option>\n ";
|
||||
}
|
||||
|
||||
function program8(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.isDefault, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data});
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.allowMultiple, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
return buffer;
|
||||
}
|
||||
function program9(depth0,data) {
|
||||
|
||||
|
||||
return "\n ";
|
||||
}
|
||||
|
||||
function program11(depth0,data) {
|
||||
|
||||
|
||||
return "\n <option selected=\"\" value=''></option>\n ";
|
||||
}
|
||||
|
||||
function program13(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n <option value='";
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.isDefault, {hash:{},inverse:self.program(16, program16, data),fn:self.program(14, program14, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
return buffer;
|
||||
}
|
||||
function program14(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n <option selected=\"\" value='";
|
||||
if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -646,7 +667,7 @@ function program9(depth0,data) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function program11(depth0,data) {
|
||||
function program16(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n <option value='";
|
||||
@@ -665,15 +686,18 @@ function program11(depth0,data) {
|
||||
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)
|
||||
+ "</td>\n<td>\n <select class='parameter' name='";
|
||||
+ "</td>\n<td>\n <select ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.allowMultiple, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += " class='parameter' 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)
|
||||
+ "'>\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.required, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data});
|
||||
stack1 = helpers['if'].call(depth0, depth0.required, {hash:{},inverse:self.program(5, program5, data),fn:self.program(3, program3, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
stack2 = helpers.each.call(depth0, ((stack1 = depth0.allowableValues),stack1 == null || stack1 === false ? stack1 : stack1.descriptiveValues), {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data});
|
||||
stack2 = helpers.each.call(depth0, ((stack1 = depth0.allowableValues),stack1 == null || stack1 === false ? stack1 : stack1.descriptiveValues), {hash:{},inverse:self.noop,fn:self.program(13, program13, data),data:data});
|
||||
if(stack2 || stack2 === 0) { buffer += stack2; }
|
||||
buffer += "\n </select>\n</td>\n<td>";
|
||||
if (stack2 = helpers.description) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
|
||||
@@ -683,7 +707,7 @@ function program11(depth0,data) {
|
||||
if (stack2 = helpers.paramType) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
|
||||
else { stack2 = depth0.paramType; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
|
||||
if(stack2 || stack2 === 0) { buffer += stack2; }
|
||||
buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
|
||||
buffer += "</td>\n<td><span class=\"model-signature\"></span></td>";
|
||||
return buffer;
|
||||
});
|
||||
})();
|
||||
@@ -1009,8 +1033,13 @@ function program4(depth0,data) {
|
||||
templates['resource'] = 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;
|
||||
var buffer = "", stack1, options, functionType="function", escapeExpression=this.escapeExpression, self=this, blockHelperMissing=helpers.blockHelperMissing;
|
||||
|
||||
function program1(depth0,data) {
|
||||
|
||||
|
||||
return " : ";
|
||||
}
|
||||
|
||||
buffer += "<div class='heading'>\n <h2>\n <a href='#!/";
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
@@ -1024,7 +1053,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "</a>\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";
|
||||
+ "</a> ";
|
||||
options = {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data};
|
||||
if (stack1 = helpers.description) { stack1 = stack1.call(depth0, options); }
|
||||
else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
if (!helpers.description) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -1144,18 +1182,18 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
|
||||
|
||||
|
||||
// Generated by CoffeeScript 1.4.0
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
(function() {
|
||||
var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi,
|
||||
var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi, _ref, _ref1, _ref10, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
|
||||
__hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
SwaggerUi = (function(_super) {
|
||||
|
||||
__extends(SwaggerUi, _super);
|
||||
|
||||
function SwaggerUi() {
|
||||
return SwaggerUi.__super__.constructor.apply(this, arguments);
|
||||
_ref = SwaggerUi.__super__.constructor.apply(this, arguments);
|
||||
return _ref;
|
||||
}
|
||||
|
||||
SwaggerUi.prototype.dom_id = "swagger_ui";
|
||||
@@ -1177,7 +1215,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
this.dom_id = options.dom_id;
|
||||
delete options.dom_id;
|
||||
}
|
||||
if (!($('#' + this.dom_id) != null)) {
|
||||
if ($('#' + this.dom_id) == null) {
|
||||
$('body').append('<div id="' + this.dom_id + '"></div>');
|
||||
}
|
||||
this.options = options;
|
||||
@@ -1204,9 +1242,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
SwaggerUi.prototype.load = function() {
|
||||
var url, _ref;
|
||||
if ((_ref = this.mainView) != null) {
|
||||
_ref.clear();
|
||||
var url, _ref1;
|
||||
if ((_ref1 = this.mainView) != null) {
|
||||
_ref1.clear();
|
||||
}
|
||||
url = this.options.url;
|
||||
if (url.indexOf("http") !== 0) {
|
||||
@@ -1243,13 +1281,24 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
SwaggerUi.prototype.buildUrl = function(base, url) {
|
||||
var parts;
|
||||
console.log("base is " + base);
|
||||
parts = base.split("/");
|
||||
base = parts[0] + "//" + parts[2];
|
||||
var endOfPath, parts;
|
||||
log("base is " + base);
|
||||
if (url.indexOf("/") === 0) {
|
||||
parts = base.split("/");
|
||||
base = parts[0] + "//" + parts[2];
|
||||
return base + url;
|
||||
} else {
|
||||
endOfPath = base.length;
|
||||
if (base.indexOf("?") > -1) {
|
||||
endOfPath = Math.min(endOfPath, base.indexOf("?"));
|
||||
}
|
||||
if (base.indexOf("#") > -1) {
|
||||
endOfPath = Math.min(endOfPath, base.indexOf("#"));
|
||||
}
|
||||
base = base.substring(0, endOfPath);
|
||||
if (base.indexOf("/", base.length - 1) !== -1) {
|
||||
return base + url;
|
||||
}
|
||||
return base + "/" + url;
|
||||
}
|
||||
};
|
||||
@@ -1284,11 +1333,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
window.SwaggerUi = SwaggerUi;
|
||||
|
||||
HeaderView = (function(_super) {
|
||||
|
||||
__extends(HeaderView, _super);
|
||||
|
||||
function HeaderView() {
|
||||
return HeaderView.__super__.constructor.apply(this, arguments);
|
||||
_ref1 = HeaderView.__super__.constructor.apply(this, arguments);
|
||||
return _ref1;
|
||||
}
|
||||
|
||||
HeaderView.prototype.events = {
|
||||
@@ -1346,21 +1395,21 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
MainView = (function(_super) {
|
||||
|
||||
__extends(MainView, _super);
|
||||
|
||||
function MainView() {
|
||||
return MainView.__super__.constructor.apply(this, arguments);
|
||||
_ref2 = MainView.__super__.constructor.apply(this, arguments);
|
||||
return _ref2;
|
||||
}
|
||||
|
||||
MainView.prototype.initialize = function() {};
|
||||
|
||||
MainView.prototype.render = function() {
|
||||
var resource, _i, _len, _ref;
|
||||
var resource, _i, _len, _ref3;
|
||||
$(this.el).html(Handlebars.templates.main(this.model));
|
||||
_ref = this.model.apisArray;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
resource = _ref[_i];
|
||||
_ref3 = this.model.apisArray;
|
||||
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
|
||||
resource = _ref3[_i];
|
||||
this.addResource(resource);
|
||||
}
|
||||
return this;
|
||||
@@ -1386,22 +1435,22 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ResourceView = (function(_super) {
|
||||
|
||||
__extends(ResourceView, _super);
|
||||
|
||||
function ResourceView() {
|
||||
return ResourceView.__super__.constructor.apply(this, arguments);
|
||||
_ref3 = ResourceView.__super__.constructor.apply(this, arguments);
|
||||
return _ref3;
|
||||
}
|
||||
|
||||
ResourceView.prototype.initialize = function() {};
|
||||
|
||||
ResourceView.prototype.render = function() {
|
||||
var operation, _i, _len, _ref;
|
||||
var operation, _i, _len, _ref4;
|
||||
$(this.el).html(Handlebars.templates.resource(this.model));
|
||||
this.number = 0;
|
||||
_ref = this.model.operationsArray;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
operation = _ref[_i];
|
||||
_ref4 = this.model.operationsArray;
|
||||
for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
|
||||
operation = _ref4[_i];
|
||||
this.addOperation(operation);
|
||||
}
|
||||
return this;
|
||||
@@ -1424,13 +1473,15 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
OperationView = (function(_super) {
|
||||
|
||||
__extends(OperationView, _super);
|
||||
|
||||
function OperationView() {
|
||||
return OperationView.__super__.constructor.apply(this, arguments);
|
||||
_ref4 = OperationView.__super__.constructor.apply(this, arguments);
|
||||
return _ref4;
|
||||
}
|
||||
|
||||
OperationView.prototype.invocationUrl = null;
|
||||
|
||||
OperationView.prototype.events = {
|
||||
'submit .sandbox': 'submitOperation',
|
||||
'click .submit': 'submitOperation',
|
||||
@@ -1441,7 +1492,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
OperationView.prototype.initialize = function() {};
|
||||
|
||||
OperationView.prototype.render = function() {
|
||||
var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||
var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7;
|
||||
isMethodSubmissionSupported = true;
|
||||
if (!isMethodSubmissionSupported) {
|
||||
this.model.isReadOnly = true;
|
||||
@@ -1466,13 +1517,13 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
contentTypeModel.consumes = this.model.consumes;
|
||||
contentTypeModel.produces = this.model.produces;
|
||||
_ref = this.model.parameters;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
param = _ref[_i];
|
||||
_ref5 = this.model.parameters;
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
param = _ref5[_i];
|
||||
type = param.type || param.dataType;
|
||||
if (type.toLowerCase() === 'file') {
|
||||
if (!contentTypeModel.consumes) {
|
||||
console.log("set content type ");
|
||||
log("set content type ");
|
||||
contentTypeModel.consumes = 'multipart/form-data';
|
||||
}
|
||||
}
|
||||
@@ -1481,14 +1532,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
model: contentTypeModel
|
||||
});
|
||||
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
|
||||
_ref1 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
param = _ref1[_j];
|
||||
_ref6 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
param = _ref6[_j];
|
||||
this.addParameter(param, contentTypeModel.consumes);
|
||||
}
|
||||
_ref2 = this.model.responseMessages;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
statusCode = _ref2[_k];
|
||||
_ref7 = this.model.responseMessages;
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
statusCode = _ref7[_k];
|
||||
this.addStatusCode(statusCode);
|
||||
}
|
||||
return this;
|
||||
@@ -1515,7 +1566,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
OperationView.prototype.submitOperation = function(e) {
|
||||
var error_free, form, map, o, opts, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||
var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7;
|
||||
if (e != null) {
|
||||
e.preventDefault();
|
||||
}
|
||||
@@ -1539,30 +1590,40 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
opts = {
|
||||
parent: this
|
||||
};
|
||||
_ref = form.find("input");
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
o = _ref[_i];
|
||||
isFileUpload = false;
|
||||
_ref5 = form.find("input");
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
o = _ref5[_i];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = encodeURI(o.value);
|
||||
map[o.name] = o.value;
|
||||
}
|
||||
if (o.type === "file") {
|
||||
isFileUpload = true;
|
||||
}
|
||||
}
|
||||
_ref1 = form.find("textarea");
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
o = _ref1[_j];
|
||||
_ref6 = form.find("textarea");
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
o = _ref6[_j];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map["body"] = o.value;
|
||||
}
|
||||
}
|
||||
_ref2 = form.find("select");
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
o = _ref2[_k];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = o.value;
|
||||
_ref7 = form.find("select");
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
o = _ref7[_k];
|
||||
val = this.getSelectedValue(o);
|
||||
if ((val != null) && jQuery.trim(val).length > 0) {
|
||||
map[o.name] = val;
|
||||
}
|
||||
}
|
||||
opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val();
|
||||
opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val();
|
||||
return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
|
||||
$(".response_throbber", $(this.el)).show();
|
||||
if (isFileUpload) {
|
||||
return this.handleFileUpload(map, form);
|
||||
} else {
|
||||
return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1570,6 +1631,105 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
return parent.showCompleteStatus(response);
|
||||
};
|
||||
|
||||
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,
|
||||
_this = this;
|
||||
log("it's a file upload");
|
||||
_ref5 = form.serializeArray();
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
o = _ref5[_i];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = o.value;
|
||||
}
|
||||
}
|
||||
bodyParam = new FormData();
|
||||
_ref6 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
param = _ref6[_j];
|
||||
if (param.paramType === 'form') {
|
||||
bodyParam.append(param.name, map[param.name]);
|
||||
}
|
||||
}
|
||||
headerParams = {};
|
||||
_ref7 = this.model.parameters;
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
param = _ref7[_k];
|
||||
if (param.paramType === 'header') {
|
||||
headerParams[param.name] = map[param.name];
|
||||
}
|
||||
}
|
||||
log(headerParams);
|
||||
_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]);
|
||||
}
|
||||
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 = {
|
||||
type: this.model.method,
|
||||
url: this.invocationUrl,
|
||||
headers: headerParams,
|
||||
data: bodyParam,
|
||||
dataType: 'json',
|
||||
contentType: false,
|
||||
processData: false,
|
||||
error: function(data, textStatus, error) {
|
||||
return _this.showErrorStatus(_this.wrap(data), _this);
|
||||
},
|
||||
success: function(data) {
|
||||
return _this.showResponse(data, _this);
|
||||
},
|
||||
complete: function(data) {
|
||||
return _this.showCompleteStatus(_this.wrap(data), _this);
|
||||
}
|
||||
};
|
||||
if (window.authorizations) {
|
||||
window.authorizations.apply(obj);
|
||||
}
|
||||
jQuery.ajax(obj);
|
||||
return false;
|
||||
};
|
||||
|
||||
OperationView.prototype.wrap = function(data) {
|
||||
var headerArray, headers, i, o, _i, _ref5, _ref6;
|
||||
headers = {};
|
||||
headerArray = data.getAllResponseHeaders().split(":");
|
||||
for (i = _i = 0, _ref5 = headerArray.length / 2, _ref6 = 2.; _ref6 > 0 ? _i <= _ref5 : _i >= _ref5; i = _i += _ref6) {
|
||||
headers[headerArray[i]] = headerArray[i + 1];
|
||||
}
|
||||
o = {};
|
||||
o.content = {};
|
||||
o.content.data = data.responseText;
|
||||
o.headers = headers;
|
||||
o.request = {};
|
||||
o.request.url = this.invocationUrl;
|
||||
o.status = data.status;
|
||||
return o;
|
||||
};
|
||||
|
||||
OperationView.prototype.getSelectedValue = function(select) {
|
||||
var opt, options, _i, _len, _ref5;
|
||||
if (!select.multiple) {
|
||||
return select.value;
|
||||
} else {
|
||||
options = [];
|
||||
_ref5 = select.options;
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
opt = _ref5[_i];
|
||||
if (opt.selected) {
|
||||
options.push(opt.value);
|
||||
}
|
||||
}
|
||||
if (options.length > 0) {
|
||||
return options.join(",");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OperationView.prototype.hideResponse = function(e) {
|
||||
if (e != null) {
|
||||
e.preventDefault();
|
||||
@@ -1645,9 +1805,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
padding = '';
|
||||
indent += transitions[fromTo];
|
||||
padding = ((function() {
|
||||
var _j, _ref, _results;
|
||||
var _j, _ref5, _results;
|
||||
_results = [];
|
||||
for (j = _j = 0, _ref = indent; 0 <= _ref ? _j < _ref : _j > _ref; j = 0 <= _ref ? ++_j : --_j) {
|
||||
for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
|
||||
_results.push(' ');
|
||||
}
|
||||
return _results;
|
||||
@@ -1665,32 +1825,34 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
return formatted;
|
||||
};
|
||||
|
||||
OperationView.prototype.showStatus = function(data) {
|
||||
OperationView.prototype.showStatus = function(response) {
|
||||
var code, content, contentType, headers, pre, response_body;
|
||||
content = data.content.data;
|
||||
headers = data.getHeaders();
|
||||
contentType = headers["Content-Type"];
|
||||
if (content === void 0) {
|
||||
content = response.data;
|
||||
headers = response.headers;
|
||||
contentType = headers && headers["Content-Type"] ? headers["Content-Type"].split(";")[0].trim() : null;
|
||||
if (!content) {
|
||||
code = $('<code />').text("no content");
|
||||
pre = $('<pre class="json" />').append(code);
|
||||
} else if (contentType.indexOf("application/json") === 0) {
|
||||
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2));
|
||||
} else if (contentType === "application/json" || /\+json$/.test(contentType)) {
|
||||
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, " "));
|
||||
pre = $('<pre class="json" />').append(code);
|
||||
} else if (contentType.indexOf("application/xml") === 0) {
|
||||
} else if (contentType === "application/xml" || /\+xml$/.test(contentType)) {
|
||||
code = $('<code />').text(this.formatXml(content));
|
||||
pre = $('<pre class="xml" />').append(code);
|
||||
} else if (contentType.indexOf("text/html") === 0) {
|
||||
} else if (contentType === "text/html") {
|
||||
code = $('<code />').html(content);
|
||||
pre = $('<pre class="xml" />').append(code);
|
||||
} else if (/^image\//.test(contentType)) {
|
||||
pre = $('<img>').attr('src', response.url);
|
||||
} else {
|
||||
code = $('<code />').text(content);
|
||||
pre = $('<pre class="json" />').append(code);
|
||||
}
|
||||
response_body = pre;
|
||||
$(".request_url").html("<pre>" + data.request.url + "</pre>");
|
||||
$(".response_code", $(this.el)).html("<pre>" + data.status + "</pre>");
|
||||
$(".request_url", $(this.el)).html("<pre>" + response.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(data.getHeaders()) + "</pre>");
|
||||
$(".response_headers", $(this.el)).html("<pre>" + JSON.stringify(response.headers, null, " ").replace(/\n/g, "<br>") + "</pre>");
|
||||
$(".response", $(this.el)).slideDown();
|
||||
$(".response_hider", $(this.el)).show();
|
||||
$(".response_throbber", $(this.el)).hide();
|
||||
@@ -1712,11 +1874,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
StatusCodeView = (function(_super) {
|
||||
|
||||
__extends(StatusCodeView, _super);
|
||||
|
||||
function StatusCodeView() {
|
||||
return StatusCodeView.__super__.constructor.apply(this, arguments);
|
||||
_ref5 = StatusCodeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref5;
|
||||
}
|
||||
|
||||
StatusCodeView.prototype.initialize = function() {};
|
||||
@@ -1737,11 +1899,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ParameterView = (function(_super) {
|
||||
|
||||
__extends(ParameterView, _super);
|
||||
|
||||
function ParameterView() {
|
||||
return ParameterView.__super__.constructor.apply(this, arguments);
|
||||
_ref6 = ParameterView.__super__.constructor.apply(this, arguments);
|
||||
return _ref6;
|
||||
}
|
||||
|
||||
ParameterView.prototype.initialize = function() {};
|
||||
@@ -1818,11 +1980,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
SignatureView = (function(_super) {
|
||||
|
||||
__extends(SignatureView, _super);
|
||||
|
||||
function SignatureView() {
|
||||
return SignatureView.__super__.constructor.apply(this, arguments);
|
||||
_ref7 = SignatureView.__super__.constructor.apply(this, arguments);
|
||||
return _ref7;
|
||||
}
|
||||
|
||||
SignatureView.prototype.events = {
|
||||
@@ -1887,11 +2049,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ContentTypeView = (function(_super) {
|
||||
|
||||
__extends(ContentTypeView, _super);
|
||||
|
||||
function ContentTypeView() {
|
||||
return ContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
_ref8 = ContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref8;
|
||||
}
|
||||
|
||||
ContentTypeView.prototype.initialize = function() {};
|
||||
@@ -1913,11 +2075,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ResponseContentTypeView = (function(_super) {
|
||||
|
||||
__extends(ResponseContentTypeView, _super);
|
||||
|
||||
function ResponseContentTypeView() {
|
||||
return ResponseContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
_ref9 = ResponseContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref9;
|
||||
}
|
||||
|
||||
ResponseContentTypeView.prototype.initialize = function() {};
|
||||
@@ -1939,11 +2101,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ParameterContentTypeView = (function(_super) {
|
||||
|
||||
__extends(ParameterContentTypeView, _super);
|
||||
|
||||
function ParameterContentTypeView() {
|
||||
return ParameterContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
_ref10 = ParameterContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref10;
|
||||
}
|
||||
|
||||
ParameterContentTypeView.prototype.initialize = function() {};
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1229
-1074
File diff suppressed because it is too large
Load Diff
+4
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "swagger-ui",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.9",
|
||||
"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",
|
||||
@@ -19,6 +19,8 @@
|
||||
"readmeFilename": "README.md",
|
||||
"dependencies": {
|
||||
"coffee-script": "~1.5.0",
|
||||
"handlebars": "~1.0.10"
|
||||
"swagger-client": "2.0.14",
|
||||
"handlebars": "~1.0.10",
|
||||
"less": "~1.4.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,14 +68,21 @@ class SwaggerUi extends Backbone.Router
|
||||
)
|
||||
|
||||
buildUrl: (base, url) ->
|
||||
console.log "base is " + base
|
||||
parts = base.split("/")
|
||||
base = parts[0] + "//" + parts[2]
|
||||
log "base is " + base
|
||||
if url.indexOf("/") is 0
|
||||
parts = base.split("/")
|
||||
base = parts[0] + "//" + parts[2]
|
||||
base + url
|
||||
else
|
||||
base + "/" + url
|
||||
|
||||
endOfPath = base.length
|
||||
if base.indexOf("?") > -1
|
||||
endOfPath = Math.min(endOfPath, base.indexOf("?"))
|
||||
if base.indexOf("#") > -1
|
||||
endOfPath = Math.min(endOfPath, base.indexOf("#"))
|
||||
base = base.substring(0, endOfPath);
|
||||
if base.indexOf( "/", base.length - 1 ) isnt -1
|
||||
return base + url
|
||||
return base + "/" + url
|
||||
|
||||
# Shows message on topbar of the ui
|
||||
showMessage: (data = '') ->
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class OperationView extends Backbone.View
|
||||
invocationUrl: null
|
||||
|
||||
events: {
|
||||
'submit .sandbox' : 'submitOperation'
|
||||
'click .submit' : 'submitOperation'
|
||||
@@ -35,7 +37,7 @@ class OperationView extends Backbone.View
|
||||
type = param.type || param.dataType
|
||||
if type.toLowerCase() == 'file'
|
||||
if !contentTypeModel.consumes
|
||||
console.log "set content type "
|
||||
log "set content type "
|
||||
contentTypeModel.consumes = 'multipart/form-data'
|
||||
|
||||
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
|
||||
@@ -77,30 +79,123 @@ class OperationView extends Backbone.View
|
||||
if error_free
|
||||
map = {}
|
||||
opts = {parent: @}
|
||||
#for o in form.serializeArray()
|
||||
#if(o.value? && jQuery.trim(o.value).length > 0)
|
||||
#map[o.name] = o.value
|
||||
|
||||
isFileUpload = false
|
||||
|
||||
for o in form.find("input")
|
||||
if(o.value? && jQuery.trim(o.value).length > 0)
|
||||
map[o.name] = encodeURI(o.value)
|
||||
map[o.name] = o.value
|
||||
if o.type is "file"
|
||||
isFileUpload = true
|
||||
|
||||
for o in form.find("textarea")
|
||||
if(o.value? && jQuery.trim(o.value).length > 0)
|
||||
map["body"] = o.value
|
||||
|
||||
for o in form.find("select")
|
||||
if(o.value? && jQuery.trim(o.value).length > 0)
|
||||
map[o.name] = o.value
|
||||
for o in form.find("select")
|
||||
val = this.getSelectedValue o
|
||||
if(val? && jQuery.trim(val).length > 0)
|
||||
map[o.name] = val
|
||||
|
||||
opts.responseContentType = $("div select[name=responseContentType]", $(@el)).val()
|
||||
opts.requestContentType = $("div select[name=parameterContentType]", $(@el)).val()
|
||||
|
||||
@model.do(map, opts, @showCompleteStatus, @showErrorStatus, @)
|
||||
$(".response_throbber", $(@el)).show()
|
||||
if isFileUpload
|
||||
@handleFileUpload map, form
|
||||
else
|
||||
@model.do(map, opts, @showCompleteStatus, @showErrorStatus, @)
|
||||
|
||||
success: (response, parent) ->
|
||||
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()
|
||||
|
||||
# add params
|
||||
for param in @model.parameters
|
||||
if param.paramType is 'form'
|
||||
bodyParam.append(param.name, map[param.name])
|
||||
|
||||
# headers in operation
|
||||
headerParams = {}
|
||||
for param in @model.parameters
|
||||
if param.paramType is 'header'
|
||||
headerParams[param.name] = map[param.name]
|
||||
|
||||
log headerParams
|
||||
|
||||
# add files
|
||||
for el in form.find('input[type~="file"]')
|
||||
bodyParam.append($(el).attr('name'), el.files[0])
|
||||
|
||||
log(bodyParam)
|
||||
|
||||
@invocationUrl =
|
||||
if @model.supportHeaderParams()
|
||||
headerParams = @model.getHeaderParams(map)
|
||||
@model.urlify(map, false)
|
||||
else
|
||||
@model.urlify(map, true)
|
||||
|
||||
$(".request_url", $(@el)).html "<pre>" + @invocationUrl + "</pre>"
|
||||
|
||||
obj =
|
||||
type: @model.method
|
||||
url: @invocationUrl
|
||||
headers: headerParams
|
||||
data: bodyParam
|
||||
dataType: 'json'
|
||||
contentType: false
|
||||
processData: false
|
||||
error: (data, textStatus, error) =>
|
||||
@showErrorStatus(@wrap(data), @)
|
||||
success: (data) =>
|
||||
@showResponse(data, @)
|
||||
complete: (data) =>
|
||||
@showCompleteStatus(@wrap(data), @)
|
||||
|
||||
# apply authorizations
|
||||
if window.authorizations
|
||||
window.authorizations.apply obj
|
||||
|
||||
jQuery.ajax(obj)
|
||||
false
|
||||
# end of file-upload nastiness
|
||||
|
||||
# wraps a jquery response as a shred response
|
||||
|
||||
wrap: (data) ->
|
||||
headers = {}
|
||||
headerArray = data.getAllResponseHeaders().split(":")
|
||||
for i in [0..headerArray.length/2] by (2)
|
||||
headers[headerArray[i]] = headerArray[i+1]
|
||||
|
||||
o = {}
|
||||
o.content = {}
|
||||
o.content.data = data.responseText
|
||||
o.headers = headers
|
||||
o.request = {}
|
||||
o.request.url = @invocationUrl
|
||||
o.status = data.status
|
||||
o
|
||||
|
||||
getSelectedValue: (select) ->
|
||||
if !select.multiple
|
||||
select.value
|
||||
else
|
||||
options = []
|
||||
options.push opt.value for opt in select.options when opt.selected
|
||||
if options.length > 0
|
||||
options.join ","
|
||||
else
|
||||
null
|
||||
|
||||
# handler for hide response link
|
||||
hideResponse: (e) ->
|
||||
@@ -182,35 +277,37 @@ class OperationView extends Backbone.View
|
||||
|
||||
|
||||
# puts the response data in UI
|
||||
showStatus: (data) ->
|
||||
content = data.content.data
|
||||
headers = data.getHeaders()
|
||||
showStatus: (response) ->
|
||||
content = response.data
|
||||
headers = response.headers
|
||||
|
||||
# if server is nice, and sends content-type back, we can use it
|
||||
contentType = headers["Content-Type"]
|
||||
contentType = if headers && headers["Content-Type"] then headers["Content-Type"].split(";")[0].trim() else null
|
||||
|
||||
if content == undefined
|
||||
if !content
|
||||
code = $('<code />').text("no content")
|
||||
pre = $('<pre class="json" />').append(code)
|
||||
else if contentType.indexOf("application/json") == 0
|
||||
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2))
|
||||
else if contentType is "application/json" || /\+json$/.test(contentType)
|
||||
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, " "))
|
||||
pre = $('<pre class="json" />').append(code)
|
||||
else if contentType.indexOf("application/xml") == 0
|
||||
else if contentType is "application/xml" || /\+xml$/.test(contentType)
|
||||
code = $('<code />').text(@formatXml(content))
|
||||
pre = $('<pre class="xml" />').append(code)
|
||||
else if contentType.indexOf("text/html") == 0
|
||||
else if contentType is "text/html"
|
||||
code = $('<code />').html(content)
|
||||
pre = $('<pre class="xml" />').append(code)
|
||||
else if /^image\//.test(contentType)
|
||||
pre = $('<img>').attr('src',response.url)
|
||||
else
|
||||
# don't know what to render!
|
||||
code = $('<code />').text(content)
|
||||
pre = $('<pre class="json" />').append(code)
|
||||
|
||||
response_body = pre
|
||||
$(".request_url").html "<pre>" + data.request.url + "</pre>"
|
||||
$(".response_code", $(@el)).html "<pre>" + data.status + "</pre>"
|
||||
$(".request_url", $(@el)).html "<pre>" + response.url + "</pre>"
|
||||
$(".response_code", $(@el)).html "<pre>" + response.status + "</pre>"
|
||||
$(".response_body", $(@el)).html response_body
|
||||
$(".response_headers", $(@el)).html "<pre>" + JSON.stringify(data.getHeaders()) + "</pre>"
|
||||
$(".response_headers", $(@el)).html "<pre>" + JSON.stringify(response.headers, null, " ").replace(/\n/g, "<br>") + "</pre>"
|
||||
$(".response", $(@el)).slideDown()
|
||||
$(".response_hider", $(@el)).show()
|
||||
$(".response_throbber", $(@el)).hide()
|
||||
|
||||
+1043
-1755
File diff suppressed because it is too large
Load Diff
@@ -2,10 +2,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Swagger UI</title>
|
||||
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
||||
<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='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||
<script type="text/javascript" src="lib/shred.bundle.js" /></script>
|
||||
<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>
|
||||
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
|
||||
@@ -23,25 +23,20 @@
|
||||
dom_id: "swagger-ui-container",
|
||||
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||
onComplete: function(swaggerApi, swaggerUi){
|
||||
if(console) {
|
||||
console.log("Loaded SwaggerUI")
|
||||
}
|
||||
log("Loaded SwaggerUI")
|
||||
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
|
||||
},
|
||||
onFailure: function(data) {
|
||||
if(console) {
|
||||
console.log("Unable to Load SwaggerUI");
|
||||
console.log(data);
|
||||
}
|
||||
log("Unable to Load SwaggerUI");
|
||||
},
|
||||
docExpansion: "none"
|
||||
});
|
||||
|
||||
$('#input_apiKey').change(function() {
|
||||
var key = $('#input_apiKey')[0].value;
|
||||
console.log("key: " + key);
|
||||
log("key: " + key);
|
||||
if(key && key.trim() != "") {
|
||||
console.log("added key " + key);
|
||||
log("added key " + key);
|
||||
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/* 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;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
@import 'src/main/less/reset.less';
|
||||
@import 'src/main/less/specs.less';
|
||||
|
||||
#header {
|
||||
background-color: #89bf04;
|
||||
padding: 14px;
|
||||
a#logo {
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
background: transparent url(../images/logo_small.png) no-repeat left center;
|
||||
padding: 20px 0 20px 40px;
|
||||
color: white;
|
||||
}
|
||||
form#api_selector {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
.input {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: left;
|
||||
margin: 0 10px 0 0;
|
||||
input#input_apiKey {
|
||||
width: 200px;
|
||||
}
|
||||
input#input_baseUrl {
|
||||
width: 400px;
|
||||
}
|
||||
a#explore {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
padding: 6px 8px;
|
||||
font-size: 0.9em;
|
||||
color: white;
|
||||
background-color: #547f00;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
-o-border-radius: 4px;
|
||||
-ms-border-radius: 4px;
|
||||
-khtml-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
a#explore:hover {
|
||||
background-color: #547f00;
|
||||
}
|
||||
input {
|
||||
font-size: 0.9em;
|
||||
padding: 3px;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#content_message {
|
||||
margin: 10px 15px;
|
||||
font-style: italic;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
#message-bar {
|
||||
min-height: 30px;
|
||||
text-align: center;
|
||||
padding-top: 10px;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,19 @@
|
||||
<td class='code'>{{name}}</td>
|
||||
<td>
|
||||
<select class='parameter' name='{{name}}'>
|
||||
<select {{#if allowMultiple}} multiple='multiple'{{/if}} class='parameter' name='{{name}}'>
|
||||
{{#if required}}
|
||||
{{else}}
|
||||
{{#if defaultValue}}
|
||||
{{else}}
|
||||
<option selected="" value=''></option>
|
||||
{{#if allowMultiple}}
|
||||
{{else}}
|
||||
<option selected="" value=''></option>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#each allowableValues.descriptiveValues}}
|
||||
{{#if isDefault}}
|
||||
<option value='{{value}}'>{{value}} (default)</option>
|
||||
<option selected="" value='{{value}}'>{{value}} (default)</option>
|
||||
{{else}}
|
||||
<option value='{{value}}'>{{value}}</option>
|
||||
{{/if}}
|
||||
@@ -19,4 +22,4 @@
|
||||
</td>
|
||||
<td>{{{description}}}</td>
|
||||
<td>{{{paramType}}}</td>
|
||||
<td><span class="model-signature"></span></td>
|
||||
<td><span class="model-signature"></span></td>
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class='heading'>
|
||||
<h2>
|
||||
<a href='#!/{{name}}' onclick="Docs.toggleEndpointListForResource('{{name}}');">{{name}}</a>
|
||||
<a href='#!/{{name}}' onclick="Docs.toggleEndpointListForResource('{{name}}');">{{name}}</a> {{#description}} : {{/description}}{{{description}}}
|
||||
</h2>
|
||||
<ul class='options'>
|
||||
<li>
|
||||
|
||||
Reference in New Issue
Block a user