\n ";
+this["Handlebars"]["templates"]["signature"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
+ return "
XML Example\n";
+ },"3":function(depth0,helpers,partials,data) {
+ return "
Click to set as parameter value";
+ },"5":function(depth0,helpers,partials,data) {
+ var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "
\n
"
+ + 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)))
+ + "
\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
\n";
+},"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 = "
\n
\n - Model
\n - Example Value
\n";
+ stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.sampleXML : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data});
+ if (stack1 != null) { buffer += stack1; }
+ buffer += "
\n
\n\n
\n
\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));
if (stack1 != null) { buffer += stack1; }
- return buffer + "\n
\n\n
\n\n
\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)))
- + "
\n
\n
\n
\n";
+ + "\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; }
+ buffer += "\n
\n";
+ 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; }
+ return buffer + "
\n";
},"useData":true});
this["Handlebars"]["templates"]["status_code"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var lambda=this.lambda, escapeExpression=this.escapeExpression;
@@ -26039,10 +26059,12 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
var type = this.model.type || this.model.dataType;
var modelType = this.model.modelSignature.type;
var modelDefinitions = this.model.modelSignature.definitions;
+ var schema = this.model.schema || {};
+ var consumes = this.model.consumes || [];
+
if (typeof type === 'undefined') {
- var schema = this.model.schema;
- if (schema && schema.$ref) {
+ if (schema.$ref) {
var ref = schema.$ref;
if (ref.indexOf('#/definitions/') === 0) {
type = ref.substring('#/definitions/'.length);
@@ -26069,11 +26091,18 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
this.model.isList = true;
}
+ var isXML = consumes.filter(function (val) {
+ if (val.indexOf('xml') > -1) {
+ return true;
+ }
+ }).length;
+
var template = this.template();
$(this.el).html(template(this.model));
var signatureModel = {
sampleJSON: SwaggerUi.partials.signature.createParameterJSONSample(modelType, modelDefinitions),
+ sampleXML: isXML ? SwaggerUi.partials.signature.createXMLSample(schema, modelDefinitions) : false,
isParam: true,
signature: SwaggerUi.partials.signature.getParameterModelSignature(modelType, modelDefinitions),
defaultRendering: this.model.defaultRendering
@@ -26978,6 +27007,8 @@ SwaggerUi.partials.signature = (function () {
xml = definition.xml || {};
$ref = definition.$ref;
+ if (!_.isObject(definition)) { return getErrorMessage(); }
+
if (_.isString($ref)) {
return getModelXML($ref, models);
}
@@ -27105,7 +27136,9 @@ SwaggerUi.Views.SignatureView = Backbone.View.extend({
events: {
'click a.description-link' : 'switchToDescription',
'click a.snippet-link' : 'switchToSnippet',
- 'mousedown .snippet' : 'snippetToTextArea'
+ 'click a.snippet-xml-link' : 'switchToXMLSnippet',
+ 'mousedown .snippet_json' : 'jsonSnippetMouseDown',
+ 'mousedown .snippet_xml' : 'xmlSnippetMouseDown'
},
initialize: function () {
@@ -27121,12 +27154,6 @@ SwaggerUi.Views.SignatureView = Backbone.View.extend({
} else {
this.switchToSnippet();
}
-
- this.isParam = this.model.isParam;
-
- if (this.isParam) {
- $('.notice', $(this.el)).text('Click to set as parameter value');
- }
return this;
},
@@ -27139,33 +27166,59 @@ SwaggerUi.Views.SignatureView = Backbone.View.extend({
$('.description', $(this.el)).show();
$('.description-link', $(this.el)).addClass('selected');
$('.snippet-link', $(this.el)).removeClass('selected');
+ $('.snippet-xml-link', $(this.el)).removeClass('selected');
},
// handler for show sample
switchToSnippet: function(e){
if (e) { e.preventDefault(); }
+ $('.snippet_json', $(this.el)).show();
$('.description', $(this.el)).hide();
- $('.snippet', $(this.el)).show();
+ $('.snippet_xml', $(this.el)).hide();
$('.snippet-link', $(this.el)).addClass('selected');
$('.description-link', $(this.el)).removeClass('selected');
+ $('.snippet-xml-link', $(this.el)).removeClass('selected');
+ },
+
+ switchToXMLSnippet: function (e) {
+ if (e) { e.preventDefault();}
+
+ $('.snippet_xml', $(this.el)).show();
+ $('.snippet_json', $(this.el)).hide();
+ $('.description', $(this.el)).hide();
+ $('.snippet-xml-link', $(this.el)).addClass('selected');
+ $('.description-link', $(this.el)).removeClass('selected');
+ $('.snippet-link', $(this.el)).removeClass('selected');
},
// handler for snippet to text area
- snippetToTextArea: function(e) {
- if (this.isParam) {
+ snippetToTextArea: function(val) {
+ var textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode));
+
+ // Fix for bug in IE 10/11 which causes placeholder text to be copied to "value"
+ if ($.trim(textArea.val()) === '' || textArea.prop('placeholder') === textArea.val()) {
+ textArea.val(val);
+ // TODO move this code outside of the view and expose an event instead
+ if( this.model.jsonEditor && this.model.jsonEditor.isEnabled()){
+ this.model.jsonEditor.setValue(JSON.parse(this.model.sampleJSON));
+ }
+ }
+ },
+
+ jsonSnippetMouseDown: function (e) {
+ if (this.model.isParam) {
if (e) { e.preventDefault(); }
- var textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode));
+ this.snippetToTextArea(this.model.sampleJSON);
+ }
+ },
- // Fix for bug in IE 10/11 which causes placeholder text to be copied to "value"
- if ($.trim(textArea.val()) === '' || textArea.prop('placeholder') === textArea.val()) {
- textArea.val(this.model.sampleJSON);
- // TODO move this code outside of the view and expose an event instead
- if( this.model.jsonEditor && this.model.jsonEditor.isEnabled()){
- this.model.jsonEditor.setValue(JSON.parse(this.model.sampleJSON));
- }
- }
+ xmlSnippetMouseDown: function (e) {
+ if (this.model.isParam) {
+ if (e) { e.preventDefault(); }
+
+ this.snippetToTextArea(this.model.sampleXML);
}
}
});
diff --git a/dist/swagger-ui.min.js b/dist/swagger-ui.min.js
index 1c13550f..4799f445 100644
--- a/dist/swagger-ui.min.js
+++ b/dist/swagger-ui.min.js
@@ -1,11 +1,11 @@
(function(){function e(){e.history=e.history||[],e.history.push(arguments),this.console&&console.log(Array.prototype.slice.call(arguments)[0])}this.Handlebars=this.Handlebars||{},this.Handlebars.templates=this.Handlebars.templates||{},this.Handlebars.templates.apikey_button_view=Handlebars.template({compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,r){var i,a="function",o=t.helperMissing,s=this.escapeExpression;return"\n
\n"},useData:!0}),this.Handlebars.templates.basic_auth_button_view=Handlebars.template({compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,r){return'
\n
\n\n'},useData:!0}),this.Handlebars.templates.content_type=Handlebars.template({1:function(e,t,n,r){var i,a="";return i=t.each.call(e,null!=e?e.produces:e,{name:"each",hash:{},fn:this.program(2,r),inverse:this.noop,data:r}),null!=i&&(a+=i),a},2:function(e,t,n,r){var i,a=this.lambda,o=this.escapeExpression,s='
\n"},4:function(e,t,n,r){return'
\n'},compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,r){var i,a,o="function",s=t.helperMissing,u=this.escapeExpression,l='
\n
\n"},useData:!0}),$(function(){$.fn.vAlign=function(){return this.each(function(){var e=$(this).height(),t=$(this).parent().height(),n=(t-e)/2;$(this).css("margin-top",n)})},$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(){var e=$(this).closest("form").innerWidth(),t=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10),n=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",e-t-n)})},$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent(),$("ul.downplayed li div.content p").vAlign(),$("form.sandbox").submit(function(){var e=!0;return $(this).find("input.required").each(function(){$(this).removeClass("error"),""===$(this).val()&&($(this).addClass("error"),$(this).wiggle(),e=!1)}),e})}),Function.prototype.bind&&console&&"object"==typeof console.log&&["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call),window.Docs={shebang:function(){var e=$.param.fragment().split("/");switch(e.shift(),e.length){case 1:if(e[0].length>0){var t="resource_"+e[0];Docs.expandEndpointListForResource(e[0]),$("#"+t).slideto({highlight:!1})}break;case 2:Docs.expandEndpointListForResource(e[0]),$("#"+t).slideto({highlight:!1});var n=e.join("_"),r=n+"_content";Docs.expandOperation($("#"+r)),$("#"+n).slideto({highlight:!1})}},toggleEndpointListForResource:function(e){var t=$("li#resource_"+Docs.escapeResourceName(e)+" ul.endpoints");t.is(":visible")?($.bbq.pushState("#/",2),Docs.collapseEndpointListForResource(e)):($.bbq.pushState("#/"+e,2),Docs.expandEndpointListForResource(e))},expandEndpointListForResource:function(e){var e=Docs.escapeResourceName(e);if(""==e)return void $(".resource ul.endpoints").slideDown();$("li#resource_"+e).addClass("active");var t=$("li#resource_"+e+" ul.endpoints");t.slideDown()},collapseEndpointListForResource:function(e){var e=Docs.escapeResourceName(e);if(""==e)return void $(".resource ul.endpoints").slideUp();$("li#resource_"+e).removeClass("active");var t=$("li#resource_"+e+" ul.endpoints");t.slideUp()},expandOperationsForResource:function(e){return Docs.expandEndpointListForResource(e),""==e?void $(".resource ul.endpoints li.operation div.content").slideDown():void $("li#resource_"+Docs.escapeResourceName(e)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(e){return Docs.expandEndpointListForResource(e),""==e?void $(".resource ul.endpoints li.operation div.content").slideUp():void $("li#resource_"+Docs.escapeResourceName(e)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(e){return e.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(e){e.slideDown()},collapseOperation:function(e){e.slideUp()}},Handlebars.registerHelper("sanitize",function(e){return e=e.replace(/