This commit is contained in:
Anna Bodnia
2016-02-23 21:08:44 +02:00
parent 253b56bbaf
commit cd4715ee99
7 changed files with 322 additions and 201 deletions

14
dist/css/print.css vendored
View File

@@ -124,11 +124,11 @@
display: block; display: block;
overflow-x: auto; overflow-x: auto;
padding: 0.5em; padding: 0.5em;
background: #f0f0f0; background: #F0F0F0;
} }
.swagger-section .hljs, .swagger-section .hljs,
.swagger-section .hljs-subst { .swagger-section .hljs-subst {
color: #444444; color: #444;
} }
.swagger-section .hljs-keyword, .swagger-section .hljs-keyword,
.swagger-section .hljs-attribute, .swagger-section .hljs-attribute,
@@ -143,7 +143,7 @@
.swagger-section .hljs-bullet, .swagger-section .hljs-bullet,
.swagger-section .hljs-code, .swagger-section .hljs-code,
.swagger-section .hljs-addition { .swagger-section .hljs-addition {
color: #1f811f; color: #1F811F;
} }
.swagger-section .hljs-regexp, .swagger-section .hljs-regexp,
.swagger-section .hljs-symbol, .swagger-section .hljs-symbol,
@@ -152,7 +152,7 @@
.swagger-section .hljs-link, .swagger-section .hljs-link,
.swagger-section .hljs-selector-attr, .swagger-section .hljs-selector-attr,
.swagger-section .hljs-selector-pseudo { .swagger-section .hljs-selector-pseudo {
color: #bc6060; color: #BC6060;
} }
.swagger-section .hljs-type, .swagger-section .hljs-type,
.swagger-section .hljs-string, .swagger-section .hljs-string,
@@ -173,7 +173,7 @@
color: #888888; color: #888888;
} }
.swagger-section .hljs-meta { .swagger-section .hljs-meta {
color: #2b6ea1; color: #2B6EA1;
} }
.swagger-section .hljs-emphasis { .swagger-section .hljs-emphasis {
font-style: italic; font-style: italic;
@@ -1181,6 +1181,10 @@
.swagger-section .oauth_submit { .swagger-section .oauth_submit {
text-align: center; text-align: center;
} }
.swagger-section .authorize__btn:hover {
text-decoration: underline;
cursor: pointer;
}
.swagger-section .auth_container .basic_auth__title { .swagger-section .auth_container .basic_auth__title {
color: #547f00; color: #547f00;
font-size: 1.2em; font-size: 1.2em;

14
dist/css/screen.css vendored
View File

@@ -124,11 +124,11 @@
display: block; display: block;
overflow-x: auto; overflow-x: auto;
padding: 0.5em; padding: 0.5em;
background: #f0f0f0; background: #F0F0F0;
} }
.swagger-section .hljs, .swagger-section .hljs,
.swagger-section .hljs-subst { .swagger-section .hljs-subst {
color: #444444; color: #444;
} }
.swagger-section .hljs-keyword, .swagger-section .hljs-keyword,
.swagger-section .hljs-attribute, .swagger-section .hljs-attribute,
@@ -143,7 +143,7 @@
.swagger-section .hljs-bullet, .swagger-section .hljs-bullet,
.swagger-section .hljs-code, .swagger-section .hljs-code,
.swagger-section .hljs-addition { .swagger-section .hljs-addition {
color: #1f811f; color: #1F811F;
} }
.swagger-section .hljs-regexp, .swagger-section .hljs-regexp,
.swagger-section .hljs-symbol, .swagger-section .hljs-symbol,
@@ -152,7 +152,7 @@
.swagger-section .hljs-link, .swagger-section .hljs-link,
.swagger-section .hljs-selector-attr, .swagger-section .hljs-selector-attr,
.swagger-section .hljs-selector-pseudo { .swagger-section .hljs-selector-pseudo {
color: #bc6060; color: #BC6060;
} }
.swagger-section .hljs-type, .swagger-section .hljs-type,
.swagger-section .hljs-string, .swagger-section .hljs-string,
@@ -173,7 +173,7 @@
color: #888888; color: #888888;
} }
.swagger-section .hljs-meta { .swagger-section .hljs-meta {
color: #2b6ea1; color: #2B6EA1;
} }
.swagger-section .hljs-emphasis { .swagger-section .hljs-emphasis {
font-style: italic; font-style: italic;
@@ -1181,6 +1181,10 @@
.swagger-section .oauth_submit { .swagger-section .oauth_submit {
text-align: center; text-align: center;
} }
.swagger-section .authorize__btn:hover {
text-decoration: underline;
cursor: pointer;
}
.swagger-section .auth_container .basic_auth__title { .swagger-section .auth_container .basic_auth__title {
color: #547f00; color: #547f00;
font-size: 1.2em; font-size: 1.2em;

451
dist/swagger-ui.js vendored
View File

@@ -12,6 +12,9 @@ this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"co
+ escapeExpression(((helper = (helper = helpers.keyName || (depth0 != null ? depth0.keyName : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"keyName","hash":{},"data":data}) : helper))) + escapeExpression(((helper = (helper = helpers.keyName || (depth0 != null ? depth0.keyName : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"keyName","hash":{},"data":data}) : helper)))
+ "</label></div>\n <input placeholder='api_key' class='auth_input input_apiKey_entry' name='apiKey' type='text'/>\n <div class='auth_submit'><a class='auth_submit_button' href='#' data-sw-translate>apply</a></div>\n </div>\n</div>\n"; + "</label></div>\n <input placeholder='api_key' class='auth_input input_apiKey_entry' name='apiKey' type='text'/>\n <div class='auth_submit'><a class='auth_submit_button' href='#' data-sw-translate>apply</a></div>\n </div>\n</div>\n";
},"useData":true}); },"useData":true});
this["Handlebars"]["templates"]["auth_button"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "<a class='authorize__btn'>Authorize</a>\n";
},"useData":true});
this["Handlebars"]["templates"]["basic_auth_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["basic_auth_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return "<div class='auth_container basic_auth_container'>\n <h3 class=\"basic_auth__title\">Basic authentication</h3>\n <form class=\"key_input_container\">\n <div class=\"auth__description\">" return "<div class='auth_container basic_auth_container'>\n <h3 class=\"basic_auth__title\">Basic authentication</h3>\n <form class=\"key_input_container\">\n <div class=\"auth__description\">"
@@ -244,6 +247,7 @@ window.Docs = {
}; };
'use strict'; 'use strict';
/*jslint eqeq: true*/
Handlebars.registerHelper('sanitize', function(html) { Handlebars.registerHelper('sanitize', function(html) {
// Strip the script tags from the html, and return it as a Handlebars.SafeString // Strip the script tags from the html, and return it as a Handlebars.SafeString
@@ -297,6 +301,29 @@ Handlebars.registerHelper('renderTextParam', function(param) {
return new Handlebars.SafeString(result); return new Handlebars.SafeString(result);
}); });
Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {
switch (operator) {
case '==':
return (v1 == v2) ? options.fn(this) : options.inverse(this);
case '===':
return (v1 === v2) ? options.fn(this) : options.inverse(this);
case '<':
return (v1 < v2) ? options.fn(this) : options.inverse(this);
case '<=':
return (v1 <= v2) ? options.fn(this) : options.inverse(this);
case '>':
return (v1 > v2) ? options.fn(this) : options.inverse(this);
case '>=':
return (v1 >= v2) ? options.fn(this) : options.inverse(this);
case '&&':
return (v1 && v2) ? options.fn(this) : options.inverse(this);
case '||':
return (v1 || v2) ? options.fn(this) : options.inverse(this);
default:
return options.inverse(this);
}
});
this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression, buffer = " <div class=\"info_title\">" var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression, buffer = " <div class=\"info_title\">"
+ escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.title : stack1), depth0)) + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.title : stack1), depth0))
@@ -382,7 +409,7 @@ this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(dept
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<div class='info' id='api_info'>\n"; var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<div class='info' id='api_info'>\n";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.info : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data}); stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.info : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data});
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
buffer += "</div>\n<div class='container' id='resources_container'>\n <div class=\"auth_main_container\"></div>\n\n <ul id='resources'></ul>\n\n <div class=\"footer\">\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: " buffer += "</div>\n<div class='container' id='resources_container'>\n <div class=\"auth_main_container\"></div>\n\n <div class='authorize-wrapper'></div>\n\n <ul id='resources'></ul>\n\n <div class=\"footer\">\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: "
+ escapeExpression(((helper = (helper = helpers.basePath || (depth0 != null ? depth0.basePath : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"basePath","hash":{},"data":data}) : helper))) + escapeExpression(((helper = (helper = helpers.basePath || (depth0 != null ? depth0.basePath : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"basePath","hash":{},"data":data}) : helper)))
+ "\n"; + "\n";
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1), {"name":"if","hash":{},"fn":this.program(14, data),"inverse":this.noop,"data":data}); stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1), {"name":"if","hash":{},"fn":this.program(14, data),"inverse":this.noop,"data":data});
@@ -822,6 +849,14 @@ this["Handlebars"]["templates"]["parameter_content_type"] = Handlebars.template(
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + "</select>\n"; return buffer + "</select>\n";
},"useData":true}); },"useData":true});
this["Handlebars"]["templates"]["popup"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<div class=\"api-popup-dialog-wrapper\">\n <div class=\"api-popup-title\">"
+ escapeExpression(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"title","hash":{},"data":data}) : helper)))
+ "</div>\n <div class=\"api-popup-content\">\n ";
stack1 = ((helper = (helper = helpers.content || (depth0 != null ? depth0.content : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"content","hash":{},"data":data}) : helper));
if (stack1 != null) { buffer += stack1; }
return buffer + "\n </div>\n <p class=\"error-msg\"></p>\n <div class=\"api-popup-actions\">\n <button class=\"api-popup-cancel api-button gray\" type=\"button\">Cancel</button>\n </div>\n</div>";
},"useData":true});
this["Handlebars"]["templates"]["resource"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["resource"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
return " : "; return " : ";
},"3":function(depth0,helpers,partials,data) { },"3":function(depth0,helpers,partials,data) {
@@ -884,32 +919,42 @@ this["Handlebars"]["templates"]["response_content_type"] = Handlebars.template({
return buffer + "</select>\n"; return buffer + "</select>\n";
},"useData":true}); },"useData":true});
this["Handlebars"]["templates"]["signature"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["signature"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = " <div class=\"snippet_json\">\n <pre><code>" var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, buffer = "\n<div>\n<ul class=\"signature-nav\">\n <li><a class=\"description-link\" href=\"#\" data-sw-translate>Model</a></li>\n <li><a class=\"snippet-link\" href=\"#\" data-sw-translate>Example Value</a></li>\n</ul>\n<div>\n\n<div class=\"signature-container\">\n <div class=\"description\">\n ";
+ escapeExpression(((helper = (helper = helpers.sampleJSON || (depth0 != null ? depth0.sampleJSON : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"sampleJSON","hash":{},"data":data}) : helper)))
+ "</code></pre>\n ";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isParam : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer + "\n </div>\n";
},"2":function(depth0,helpers,partials,data) {
return "<small class=\"notice\" data-sw-translate></small>";
},"4":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = " <div class=\"snippet_xml\">\n <pre><code>"
+ escapeExpression(((helper = (helper = helpers.sampleXML || (depth0 != null ? depth0.sampleXML : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"sampleXML","hash":{},"data":data}) : helper)))
+ "</code></pre>\n ";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isParam : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer + "\n </div>\n";
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, buffer = "<div>\n<ul class=\"signature-nav\">\n <li><a class=\"description-link\" href=\"#\" data-sw-translate>Model</a></li>\n <li><a class=\"snippet-link\" href=\"#\" data-sw-translate>Example Value</a></li>\n</ul>\n<div>\n\n<div class=\"signature-container\">\n <div class=\"description\">\n ";
stack1 = ((helper = (helper = helpers.signature || (depth0 != null ? depth0.signature : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"signature","hash":{},"data":data}) : helper)); stack1 = ((helper = (helper = helpers.signature || (depth0 != null ? depth0.signature : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"signature","hash":{},"data":data}) : helper));
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
buffer += "\n </div>\n\n <div class=\"snippet\">\n"; buffer += "\n </div>\n\n <div class=\"snippet\">\n";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.sampleJSON : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data}); stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.sampleJSON : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.sampleXML : depth0), {"name":"if","hash":{},"fn":this.program(4, data),"inverse":this.noop,"data":data}); stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.sampleXML : depth0), {"name":"if","hash":{},"fn":this.program(5, data),"inverse":this.noop,"data":data});
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + " </div>\n</div>\n"; return buffer + " </div>\n</div>\n";
},"useData":true}); },"2":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = " <div class=\"snippet_json\">\n <pre><code>"
+ escapeExpression(((helper = (helper = helpers.sampleJSON || (depth0 != null ? depth0.sampleJSON : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"sampleJSON","hash":{},"data":data}) : helper)))
+ "</code></pre>\n ";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isParam : depth0), {"name":"if","hash":{},"fn":this.program(3, data),"inverse":this.noop,"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer + "\n </div>\n";
},"3":function(depth0,helpers,partials,data) {
return "<small class=\"notice\" data-sw-translate></small>";
},"5":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = " <div class=\"snippet_xml\">\n <pre><code>"
+ escapeExpression(((helper = (helper = helpers.sampleXML || (depth0 != null ? depth0.sampleXML : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"sampleXML","hash":{},"data":data}) : helper)))
+ "</code></pre>\n ";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isParam : depth0), {"name":"if","hash":{},"fn":this.program(3, data),"inverse":this.noop,"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer + "\n </div>\n";
},"7":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " "
+ escapeExpression(((helper = (helper = helpers.signature || (depth0 != null ? depth0.signature : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"signature","hash":{},"data":data}) : helper)))
+ "\n";
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helperMissing=helpers.helperMissing;
stack1 = ((helpers.ifCond || (depth0 && depth0.ifCond) || helperMissing).call(depth0, (depth0 != null ? depth0.sampleJSON : depth0), "||", (depth0 != null ? depth0.sampleXML : depth0), {"name":"ifCond","hash":{},"fn":this.program(1, data),"inverse":this.program(7, data),"data":data}));
if (stack1 != null) { return stack1; }
else { return ''; }
},"useData":true});
this["Handlebars"]["templates"]["status_code"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["status_code"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var lambda=this.lambda, escapeExpression=this.escapeExpression; var lambda=this.lambda, escapeExpression=this.escapeExpression;
return " <tr>\n <td>" return " <tr>\n <td>"
@@ -24997,7 +25042,7 @@ SwaggerUi.Views.ApiKeyButton = Backbone.View.extend({ // TODO: append this to gl
}, },
render: function(){ render: function(){
$(this.el).html(this.template(this.model)); this.$el.html(this.template(this.model));
return this; return this;
}, },
@@ -25017,6 +25062,59 @@ SwaggerUi.Views.ApiKeyButton = Backbone.View.extend({ // TODO: append this to gl
}); });
'use strict'; 'use strict';
SwaggerUi.Views.AuthView = Backbone.View.extend({
events: {
'click .authorize__btn': 'authorizeBtnClick'
},
tpls: {
popup: Handlebars.templates.popup,
authBtn: Handlebars.templates.auth_button
},
initialize: function(){},
render: function () {
this.$el.html(this.tpls.authBtn());
return this;
},
authorizeBtnClick: function (e) {
var authsModel;
e.preventDefault();
authsModel = {title: 'Please authorize', content: this.renderAuths()};
this.popup = new SwaggerUi.Views.PopupView({model: authsModel});
this.popup.render();
},
renderAuths: function () {
var name, authEl, auth;
var el = $('<div>');
//todo refactor, copy-pasted from MainView.js
for (name in this.model) {
auth = this.model[name];
if (auth.type === 'apiKey') {
authEl = new SwaggerUi.Views.ApiKeyButton({model: auth, router: this.router}).render().el;
el.append(authEl);
}
if (auth.type === 'basic' && el.find('.basic_auth_container').length === 0) {
authEl = new SwaggerUi.Views.BasicAuthButton({model: auth, router: this.router}).render().el;
el.append(authEl);
}
}
return el.html();
}
});
'use strict';
SwaggerUi.Views.BasicAuthButton = Backbone.View.extend({ SwaggerUi.Views.BasicAuthButton = Backbone.View.extend({
@@ -25192,24 +25290,13 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
}, },
render: function () { render: function () {
var name, authEl, auth;
// Render the outer container for resources // Render the outer container for resources
$(this.el).html(Handlebars.templates.main(this.model)); $(this.el).html(Handlebars.templates.main(this.model));
this.model.securityDefinitions = this.model.securityDefinitions || {}; this.model.securityDefinitions = this.model.securityDefinitions || {};
for (name in this.model.securityDefinitions) { if (this.model.securityDefinitions) {
auth = this.model.securityDefinitions[name]; this.authView = new SwaggerUi.Views.AuthView({model: this.model.securityDefinitions});
this.$('.authorize-wrapper').append(this.authView.render().el);
if (auth.type === 'apiKey') {
authEl = new SwaggerUi.Views.ApiKeyButton({model: auth, router: this.router}).render().el;
$('.auth_main_container').append(authEl);
}
if (auth.type === 'basic' && $('.auth_main_container .basic_auth_container').length === 0) {
authEl = new SwaggerUi.Views.BasicAuthButton({model: auth, router: this.router}).render().el;
$('.auth_main_container').append(authEl);
}
} }
// Render each resource // Render each resource
@@ -25305,21 +25392,21 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
}, },
selectText: function(event) { selectText: function(event) {
var doc = document, var doc = document,
text = event.target.firstChild, text = event.target.firstChild,
range, range,
selection; selection;
if (doc.body.createTextRange) { if (doc.body.createTextRange) {
range = document.body.createTextRange(); range = document.body.createTextRange();
range.moveToElementText(text); range.moveToElementText(text);
range.select(); range.select();
} else if (window.getSelection) { } else if (window.getSelection) {
selection = window.getSelection(); selection = window.getSelection();
range = document.createRange(); range = document.createRange();
range.selectNodeContents(text); range.selectNodeContents(text);
selection.removeAllRanges(); selection.removeAllRanges();
selection.addRange(range); selection.addRange(range);
} }
}, },
mouseEnter: function(e) { mouseEnter: function(e) {
@@ -25364,9 +25451,54 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
this.model.isReadOnly = true; this.model.isReadOnly = true;
} }
this.model.description = this.model.description || this.model.notes; this.model.description = this.model.description || this.model.notes;
this.model.oauth = null;
this.handleAuth(); modelAuths = this.model.authorizations || this.model.security;
if (modelAuths) {
if (Array.isArray(modelAuths)) {
for (l = 0, len = modelAuths.length; l < len; l++) {
auths = modelAuths[l];
for (key in auths) {
for (a in this.auths) {
auth = this.auths[a];
if (key === auth.name) {
if (auth.type === 'oauth2') {
this.model.oauth = {};
this.model.oauth.scopes = [];
ref1 = auth.value.scopes;
for (k in ref1) {
v = ref1[k];
scopeIndex = auths[key].indexOf(k);
if (scopeIndex >= 0) {
o = {
scope: k,
description: v
};
this.model.oauth.scopes.push(o);
}
}
}
}
}
}
}
} else {
for (k in modelAuths) {
v = modelAuths[k];
if (k === 'oauth2') {
if (this.model.oauth === null) {
this.model.oauth = {};
}
if (this.model.oauth.scopes === void 0) {
this.model.oauth.scopes = [];
}
for (m = 0, len1 = v.length; m < len1; m++) {
o = v[m];
this.model.oauth.scopes.push(o);
}
}
}
}
}
if (typeof this.model.responses !== 'undefined') { if (typeof this.model.responses !== 'undefined') {
this.model.responseMessages = []; this.model.responseMessages = [];
ref2 = this.model.responses; ref2 = this.model.responses;
@@ -25411,6 +25543,10 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
sampleXML: isXML ? SwaggerUi.partials.signature.createXMLSample(value.definition, value.models) : false, sampleXML: isXML ? SwaggerUi.partials.signature.createXMLSample(value.definition, value.models) : false,
signature: SwaggerUi.partials.signature.getModelSignature(value.name, value.definition, value.models, value.modelPropertyMacro) signature: SwaggerUi.partials.signature.getModelSignature(value.name, value.definition, value.models, value.modelPropertyMacro)
}; };
} else {
signatureModel = {
signature: SwaggerUi.partials.signature.getPrimitiveSignature(value)
};
} }
} }
} else if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') { } else if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') {
@@ -25716,7 +25852,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
// wraps a jquery response as a shred response // wraps a jquery response as a shred response
wrap: function(data) { wrap: function(data) {
var h, headerArray, headers, i, l, len, o; var h, headerArray, headers, i, l, len, o;
headers = {}; headers = {};
headerArray = data.getAllResponseHeaders().split('\r'); headerArray = data.getAllResponseHeaders().split('\r');
for (l = 0, len = headerArray.length; l < len; l++) { for (l = 0, len = headerArray.length; l < len; l++) {
@@ -25893,7 +26029,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
code = $('<code />').text('no content'); code = $('<code />').text('no content');
pre = $('<pre class="json" />').append(code); pre = $('<pre class="json" />').append(code);
// JSON // JSON
} else if (contentType === 'application/json' || /\+json$/.test(contentType)) { } else if (contentType === 'application/json' || /\+json$/.test(contentType)) {
var json = null; var json = null;
try { try {
@@ -25904,35 +26040,35 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
code = $('<code />').text(json); code = $('<code />').text(json);
pre = $('<pre class="json" />').append(code); pre = $('<pre class="json" />').append(code);
// XML // XML
} else if (contentType === 'application/xml' || /\+xml$/.test(contentType)) { } else if (contentType === 'application/xml' || /\+xml$/.test(contentType)) {
code = $('<code />').text(this.formatXml(content)); code = $('<code />').text(this.formatXml(content));
pre = $('<pre class="xml" />').append(code); pre = $('<pre class="xml" />').append(code);
// HTML // HTML
} else if (contentType === 'text/html') { } else if (contentType === 'text/html') {
code = $('<code />').html(_.escape(content)); code = $('<code />').html(_.escape(content));
pre = $('<pre class="xml" />').append(code); pre = $('<pre class="xml" />').append(code);
// Plain Text // Plain Text
} else if (/text\/plain/.test(contentType)) { } else if (/text\/plain/.test(contentType)) {
code = $('<code />').text(content); code = $('<code />').text(content);
pre = $('<pre class="plain" />').append(code); pre = $('<pre class="plain" />').append(code);
// Image // Image
} else if (/^image\//.test(contentType)) { } else if (/^image\//.test(contentType)) {
pre = $('<img>').attr('src', url); pre = $('<img>').attr('src', url);
// Audio // Audio
} else if (/^audio\//.test(contentType) && supportsAudioPlayback(contentType)) { } else if (/^audio\//.test(contentType) && supportsAudioPlayback(contentType)) {
pre = $('<audio controls>').append($('<source>').attr('src', url).attr('type', contentType)); pre = $('<audio controls>').append($('<source>').attr('src', url).attr('type', contentType));
// Download // Download
} else if (headers['Content-Disposition'] && (/attachment/).test(headers['Content-Disposition']) || } else if (headers['Content-Disposition'] && (/attachment/).test(headers['Content-Disposition']) ||
headers['content-disposition'] && (/attachment/).test(headers['content-disposition']) || headers['content-disposition'] && (/attachment/).test(headers['content-disposition']) ||
headers['Content-Description'] && (/File Transfer/).test(headers['Content-Description']) || headers['Content-Description'] && (/File Transfer/).test(headers['Content-Description']) ||
headers['content-description'] && (/File Transfer/).test(headers['content-description'])) { headers['content-description'] && (/File Transfer/).test(headers['content-description'])) {
if ('Blob' in window) { if ('Blob' in window) {
var type = contentType || 'text/html'; var type = contentType || 'text/html';
@@ -25951,11 +26087,11 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
pre = $('<pre class="json" />').append('Download headers detected but your browser does not support downloading binary via XHR (Blob).'); pre = $('<pre class="json" />').append('Download headers detected but your browser does not support downloading binary via XHR (Blob).');
} }
// Location header based redirect download // Location header based redirect download
} else if(headers.location || headers.Location) { } else if(headers.location || headers.Location) {
window.location = response.url; window.location = response.url;
// Anything else (CORS) // Anything else (CORS)
} else { } else {
code = $('<code />').text(content); code = $('<code />').text(content);
pre = $('<pre class="json" />').append(code); pre = $('<pre class="json" />').append(code);
@@ -25981,8 +26117,8 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
if (opts.showRequestHeaders) { if (opts.showRequestHeaders) {
var form = $('.sandbox', $(this.el)), var form = $('.sandbox', $(this.el)),
map = this.getInputMap(form), map = this.getInputMap(form),
requestHeaders = this.model.getHeaderParams(map); requestHeaders = this.model.getHeaderParams(map);
delete requestHeaders['Content-Type']; delete requestHeaders['Content-Type'];
$('.request_headers', $(this.el)).html('<pre>' + _.escape(JSON.stringify(requestHeaders, null, ' ')).replace(/\n/g, '<br>') + '</pre>'); $('.request_headers', $(this.el)).html('<pre>' + _.escape(JSON.stringify(requestHeaders, null, ' ')).replace(/\n/g, '<br>') + '</pre>');
} }
@@ -26055,95 +26191,6 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
} }
} }
return null; return null;
},
handleAuth: function () {
var modelAuths, auths, i, l, len, len1, ref1, scopeIndex;
var definitionsMap = {};
this.auths = this.auths || [];
for (l = 0, len = this.auths.length; l < len; l++) {
definitionsMap[this.auths[l].name] = this.auths[l].value;
}
this.model.oauth = null;
modelAuths = this.model.authorizations || this.model.security;
if (!modelAuths) { return null; }
if (Array.isArray(modelAuths)) {
modelAuths.forEach(function (security) {
for (i in security) {
security[i] = security[i] || {};
switch (security[i].type) {
case 'apiKey': break;
case 'basic': break;
default:
//handle from definitions
}
}
});
}
if (Array.isArray(modelAuths)) {
for (l = 0, len = modelAuths.length; l < len; l++) {
//auths - single auth from security
auths = modelAuths[l];
for (key in auths) {
//this.auths - auth from definitions
for (a in this.auths) {
//auth - one single auth from definition
auth = this.auths[a];
// if security name is in definitions
if (key === auth.name) {
if (auth.type === 'oauth2') {
this.model.oauth = {};
this.model.oauth.scopes = [];
ref1 = auth.value.scopes;
for (k in ref1) {
v = ref1[k];
scopeIndex = auths[key].indexOf(k);
if (scopeIndex >= 0) {
o = {
scope: k,
description: v
};
this.model.oauth.scopes.push(o);
}
}
}
//if (auth.type === 'apiKey') {
// console.log('apiKey')
//}
}
}
}
}
} else {
for (k in modelAuths) {
v = modelAuths[k];
if (k === 'oauth2') {
if (this.model.oauth === null) {
this.model.oauth = {};
}
if (this.model.oauth.scopes === void 0) {
this.model.oauth.scopes = [];
}
for (m = 0, len1 = v.length; m < len1; m++) {
o = v[m];
this.model.oauth.scopes.push(o);
}
}
}
}
} }
}); });
@@ -26183,6 +26230,7 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
var modelDefinitions = this.model.modelSignature.definitions; var modelDefinitions = this.model.modelSignature.definitions;
var schema = this.model.schema || {}; var schema = this.model.schema || {};
var consumes = this.model.consumes || []; var consumes = this.model.consumes || [];
var sampleJSON, signatureView;
if (typeof type === 'undefined') { if (typeof type === 'undefined') {
@@ -26215,20 +26263,21 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
var isXML = this.contains(consumes, 'xml'); var isXML = this.contains(consumes, 'xml');
var isJSON = isXML ? this.contains(consumes, 'json') : true; var isJSON = isXML ? this.contains(consumes, 'json') : true;
sampleJSON = SwaggerUi.partials.signature.createParameterJSONSample(modelType, modelDefinitions);
var template = this.template(); var template = this.template();
$(this.el).html(template(this.model)); $(this.el).html(template(this.model));
var signatureModel = { var signatureModel = {
sampleJSON: isJSON ? SwaggerUi.partials.signature.createParameterJSONSample(modelType, modelDefinitions) : false, sampleJSON: isJSON ? sampleJSON : false,
sampleXML: isXML ? SwaggerUi.partials.signature.createXMLSample(schema, modelDefinitions, true) : false, sampleXML: sampleJSON && isXML ? SwaggerUi.partials.signature.createXMLSample(schema, modelDefinitions, true) : false,
isParam: true, isParam: true,
signature: SwaggerUi.partials.signature.getParameterModelSignature(modelType, modelDefinitions), signature: SwaggerUi.partials.signature.getParameterModelSignature(modelType, modelDefinitions),
defaultRendering: this.model.defaultRendering defaultRendering: this.model.defaultRendering
}; };
if (this.model.sampleJSON) { if (sampleJSON) {
var signatureView = new SwaggerUi.Views.SignatureView({model: signatureModel, tagName: 'div'}); signatureView = new SwaggerUi.Views.SignatureView({model: signatureModel, tagName: 'div'});
$('.model-signature', $(this.el)).append(signatureView.render().el); $('.model-signature', $(this.el)).append(signatureView.render().el);
} }
else { else {
@@ -26316,6 +26365,7 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
}, },
toggleSnippet: function (type) { toggleSnippet: function (type) {
type = type || '';
if (type.indexOf('xml') > -1) { if (type.indexOf('xml') > -1) {
this.$('.snippet_xml').show(); this.$('.snippet_xml').show();
this.$('.snippet_json').hide(); this.$('.snippet_json').hide();
@@ -27085,6 +27135,20 @@ SwaggerUi.partials.signature = (function () {
return value; return value;
}; };
var getPrimitiveSignature = function (schema) {
var type, items;
schema = schema || {};
items = schema.items || {};
type = schema.type || '';
switch (type) {
case 'object': return 'Object is not a primitive';
case 'array' : return 'Array[' + (items.format || items.type) + ']';
default: return schema.format || type;
}
};
var createPrimitiveXML = function (descriptor) { var createPrimitiveXML = function (descriptor) {
var name = descriptor.name; var name = descriptor.name;
var definition = descriptor.definition; var definition = descriptor.definition;
@@ -27273,13 +27337,59 @@ SwaggerUi.partials.signature = (function () {
getParameterModelSignature: getParameterModelSignature, getParameterModelSignature: getParameterModelSignature,
createParameterJSONSample: createParameterJSONSample, createParameterJSONSample: createParameterJSONSample,
createSchemaXML: createSchemaXML, createSchemaXML: createSchemaXML,
createXMLSample: createXMLSample createXMLSample: createXMLSample,
getPrimitiveSignature: getPrimitiveSignature
}; };
})(); })();
'use strict'; 'use strict';
SwaggerUi.Views.PopupView = Backbone.View.extend({
events: {
'click .api-popup-cancel': 'cancelClick'
},
template: Handlebars.templates.popup,
className: 'api-popup-dialog',
initialize: function(){},
render: function () {
var $win, dw, dh, st, dlgWd, dlgHt, top, left;
$win = $(window);
dw = $win.width();
dh = $win.height();
st = $win.scrollTop();
this.$el.html(this.template(this.model));
$(document.body).append(this.el);
dlgWd = this.$el.outerWidth();
dlgHt = this.$el.outerHeight();
top = (dh -dlgHt)/2 + st;
left = (dw - dlgWd)/2;
this.$el.css({
top: (top < 0? 0 : top) + 'px',
left: (left < 0? 0 : left) + 'px'
});
this.showPopup();
return this;
},
showPopup: function () {
this.$el.show();
},
cancelClick: function () {
this.remove();
}
});
'use strict';
SwaggerUi.Views.ResourceView = Backbone.View.extend({ SwaggerUi.Views.ResourceView = Backbone.View.extend({
initialize: function(opts) { initialize: function(opts) {
opts = opts || {}; opts = opts || {};
@@ -27448,23 +27558,26 @@ SwaggerUi.Views.StatusCodeView = Backbone.View.extend({
}, },
render: function(){ render: function(){
var responseModel, responseModelView;
var value = this.router.api.models[this.model.responseModel]; var value = this.router.api.models[this.model.responseModel];
$(this.el).html(Handlebars.templates.status_code(this.model)); $(this.el).html(Handlebars.templates.status_code(this.model));
if (this.router.api.models.hasOwnProperty(this.model.responseModel)) { if (this.router.api.models.hasOwnProperty(this.model.responseModel)) {
var responseModel = { responseModel = {
sampleJSON: JSON.stringify(SwaggerUi.partials.signature.createJSONSample(value), void 0, 2), sampleJSON: JSON.stringify(SwaggerUi.partials.signature.createJSONSample(value), void 0, 2),
sampleXML: this.model.isXML ? SwaggerUi.partials.signature.createXMLSample(this.model.schema, value.models) : false, sampleXML: this.model.isXML ? SwaggerUi.partials.signature.createXMLSample(this.model.schema, this.router.api.models) : false,
isParam: false, isParam: false,
signature: SwaggerUi.partials.signature.getModelSignature(this.model.responseModel, value, this.router.api.models), signature: SwaggerUi.partials.signature.getModelSignature(this.model.responseModel, value, this.router.api.models),
defaultRendering: this.model.defaultRendering defaultRendering: this.model.defaultRendering
}; };
var responseModelView = new SwaggerUi.Views.SignatureView({model: responseModel, tagName: 'div'});
$('.model-signature', this.$el).append(responseModelView.render().el);
} else { } else {
$('.model-signature', this.$el).html(''); responseModel = {
signature: SwaggerUi.partials.signature.getPrimitiveSignature(this.model.schema)
};
} }
responseModelView = new SwaggerUi.Views.SignatureView({model: responseModel, tagName: 'div'});
$('.model-signature', this.$el).append(responseModelView.render().el);
return this; return this;
} }
});}).call(this); });}).call(this);

File diff suppressed because one or more lines are too long

View File

@@ -124,11 +124,11 @@
display: block; display: block;
overflow-x: auto; overflow-x: auto;
padding: 0.5em; padding: 0.5em;
background: #f0f0f0; background: #F0F0F0;
} }
.swagger-section .hljs, .swagger-section .hljs,
.swagger-section .hljs-subst { .swagger-section .hljs-subst {
color: #444444; color: #444;
} }
.swagger-section .hljs-keyword, .swagger-section .hljs-keyword,
.swagger-section .hljs-attribute, .swagger-section .hljs-attribute,
@@ -143,7 +143,7 @@
.swagger-section .hljs-bullet, .swagger-section .hljs-bullet,
.swagger-section .hljs-code, .swagger-section .hljs-code,
.swagger-section .hljs-addition { .swagger-section .hljs-addition {
color: #1f811f; color: #1F811F;
} }
.swagger-section .hljs-regexp, .swagger-section .hljs-regexp,
.swagger-section .hljs-symbol, .swagger-section .hljs-symbol,
@@ -152,7 +152,7 @@
.swagger-section .hljs-link, .swagger-section .hljs-link,
.swagger-section .hljs-selector-attr, .swagger-section .hljs-selector-attr,
.swagger-section .hljs-selector-pseudo { .swagger-section .hljs-selector-pseudo {
color: #bc6060; color: #BC6060;
} }
.swagger-section .hljs-type, .swagger-section .hljs-type,
.swagger-section .hljs-string, .swagger-section .hljs-string,
@@ -173,7 +173,7 @@
color: #888888; color: #888888;
} }
.swagger-section .hljs-meta { .swagger-section .hljs-meta {
color: #2b6ea1; color: #2B6EA1;
} }
.swagger-section .hljs-emphasis { .swagger-section .hljs-emphasis {
font-style: italic; font-style: italic;

View File

@@ -124,11 +124,11 @@
display: block; display: block;
overflow-x: auto; overflow-x: auto;
padding: 0.5em; padding: 0.5em;
background: #f0f0f0; background: #F0F0F0;
} }
.swagger-section .hljs, .swagger-section .hljs,
.swagger-section .hljs-subst { .swagger-section .hljs-subst {
color: #444444; color: #444;
} }
.swagger-section .hljs-keyword, .swagger-section .hljs-keyword,
.swagger-section .hljs-attribute, .swagger-section .hljs-attribute,
@@ -143,7 +143,7 @@
.swagger-section .hljs-bullet, .swagger-section .hljs-bullet,
.swagger-section .hljs-code, .swagger-section .hljs-code,
.swagger-section .hljs-addition { .swagger-section .hljs-addition {
color: #1f811f; color: #1F811F;
} }
.swagger-section .hljs-regexp, .swagger-section .hljs-regexp,
.swagger-section .hljs-symbol, .swagger-section .hljs-symbol,
@@ -152,7 +152,7 @@
.swagger-section .hljs-link, .swagger-section .hljs-link,
.swagger-section .hljs-selector-attr, .swagger-section .hljs-selector-attr,
.swagger-section .hljs-selector-pseudo { .swagger-section .hljs-selector-pseudo {
color: #bc6060; color: #BC6060;
} }
.swagger-section .hljs-type, .swagger-section .hljs-type,
.swagger-section .hljs-string, .swagger-section .hljs-string,
@@ -173,7 +173,7 @@
color: #888888; color: #888888;
} }
.swagger-section .hljs-meta { .swagger-section .hljs-meta {
color: #2b6ea1; color: #2B6EA1;
} }
.swagger-section .hljs-emphasis { .swagger-section .hljs-emphasis {
font-style: italic; font-style: italic;

View File

@@ -36,7 +36,7 @@
if (url && url.length > 1) { if (url && url.length > 1) {
url = decodeURIComponent(url[1]); url = decodeURIComponent(url[1]);
} else { } else {
url = "http://localhost:3001/swagger.json"; url = "http://petstore.swagger.io/v2/swagger.json";
} }
hljs.configure({ hljs.configure({