fixes #1186 Render primitive types in "Response Class"
This commit is contained in:
2
dist/css/print.css
vendored
2
dist/css/print.css
vendored
@@ -82,7 +82,7 @@
|
|||||||
.swagger-section pre .vhdl .attribute,
|
.swagger-section pre .vhdl .attribute,
|
||||||
.swagger-section pre .clojure .attribute,
|
.swagger-section pre .clojure .attribute,
|
||||||
.swagger-section pre .coffeescript .property {
|
.swagger-section pre .coffeescript .property {
|
||||||
color: #8888ff;
|
color: #88F;
|
||||||
}
|
}
|
||||||
.swagger-section pre .keyword,
|
.swagger-section pre .keyword,
|
||||||
.swagger-section pre .id,
|
.swagger-section pre .id,
|
||||||
|
|||||||
2
dist/css/screen.css
vendored
2
dist/css/screen.css
vendored
@@ -82,7 +82,7 @@
|
|||||||
.swagger-section pre .vhdl .attribute,
|
.swagger-section pre .vhdl .attribute,
|
||||||
.swagger-section pre .clojure .attribute,
|
.swagger-section pre .clojure .attribute,
|
||||||
.swagger-section pre .coffeescript .property {
|
.swagger-section pre .coffeescript .property {
|
||||||
color: #8888ff;
|
color: #88F;
|
||||||
}
|
}
|
||||||
.swagger-section pre .keyword,
|
.swagger-section pre .keyword,
|
||||||
.swagger-section pre .id,
|
.swagger-section pre .id,
|
||||||
|
|||||||
103
dist/swagger-ui.js
vendored
103
dist/swagger-ui.js
vendored
@@ -294,6 +294,13 @@ Handlebars.registerHelper('renderTextParam', function(param) {
|
|||||||
return new Handlebars.SafeString(result);
|
return new Handlebars.SafeString(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Handlebars.registerHelper('if_or', function(v1, v2, options) {
|
||||||
|
if (v1 || v2) {
|
||||||
|
return options.fn(this);
|
||||||
|
}
|
||||||
|
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))
|
||||||
@@ -881,31 +888,41 @@ 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";
|
||||||
|
},"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.if_or || (depth0 && depth0.if_or) || helperMissing).call(depth0, (depth0 != null ? depth0.sampleJSON : depth0), (depth0 != null ? depth0.sampleXML : depth0), {"name":"if_or","hash":{},"fn":this.program(1, data),"inverse":this.program(7, data),"data":data}));
|
||||||
|
if (stack1 != null) { return stack1; }
|
||||||
|
else { return ''; }
|
||||||
},"useData":true});
|
},"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;
|
||||||
@@ -25107,7 +25124,7 @@ SwaggerUi.Views.HeaderView = Backbone.View.extend({
|
|||||||
|
|
||||||
showPetStore: function(){
|
showPetStore: function(){
|
||||||
this.trigger('update-swagger-ui', {
|
this.trigger('update-swagger-ui', {
|
||||||
url:'http://petstore.swagger.io/v2/swagger.json'
|
url:'http://localhost:3001/order2.json'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -25480,6 +25497,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') {
|
||||||
@@ -26163,6 +26184,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') {
|
||||||
@@ -26195,20 +26217,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 {
|
||||||
@@ -27065,6 +27088,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.type + ']';
|
||||||
|
default: return 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;
|
||||||
@@ -27253,7 +27290,8 @@ SwaggerUi.partials.signature = (function () {
|
|||||||
getParameterModelSignature: getParameterModelSignature,
|
getParameterModelSignature: getParameterModelSignature,
|
||||||
createParameterJSONSample: createParameterJSONSample,
|
createParameterJSONSample: createParameterJSONSample,
|
||||||
createSchemaXML: createSchemaXML,
|
createSchemaXML: createSchemaXML,
|
||||||
createXMLSample: createXMLSample
|
createXMLSample: createXMLSample,
|
||||||
|
getPrimitiveSignature: getPrimitiveSignature
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
@@ -27429,23 +27467,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);
|
||||||
18
dist/swagger-ui.min.js
vendored
18
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -82,7 +82,7 @@
|
|||||||
.swagger-section pre .vhdl .attribute,
|
.swagger-section pre .vhdl .attribute,
|
||||||
.swagger-section pre .clojure .attribute,
|
.swagger-section pre .clojure .attribute,
|
||||||
.swagger-section pre .coffeescript .property {
|
.swagger-section pre .coffeescript .property {
|
||||||
color: #8888ff;
|
color: #88F;
|
||||||
}
|
}
|
||||||
.swagger-section pre .keyword,
|
.swagger-section pre .keyword,
|
||||||
.swagger-section pre .id,
|
.swagger-section pre .id,
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
.swagger-section pre .vhdl .attribute,
|
.swagger-section pre .vhdl .attribute,
|
||||||
.swagger-section pre .clojure .attribute,
|
.swagger-section pre .clojure .attribute,
|
||||||
.swagger-section pre .coffeescript .property {
|
.swagger-section pre .coffeescript .property {
|
||||||
color: #8888ff;
|
color: #88F;
|
||||||
}
|
}
|
||||||
.swagger-section pre .keyword,
|
.swagger-section pre .keyword,
|
||||||
.swagger-section pre .id,
|
.swagger-section pre .id,
|
||||||
|
|||||||
@@ -51,3 +51,11 @@ Handlebars.registerHelper('renderTextParam', function(param) {
|
|||||||
}
|
}
|
||||||
return new Handlebars.SafeString(result);
|
return new Handlebars.SafeString(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Handlebars.registerHelper('if_or', function(v1, v2, options) {
|
||||||
|
if (v1 || v2) {
|
||||||
|
return options.fn(this);
|
||||||
|
}
|
||||||
|
return options.inverse(this);
|
||||||
|
});
|
||||||
@@ -183,6 +183,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') {
|
||||||
|
|||||||
@@ -21,6 +21,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') {
|
||||||
@@ -53,20 +54,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 {
|
||||||
|
|||||||
@@ -7,23 +7,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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -736,6 +736,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.type + ']';
|
||||||
|
default: return 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;
|
||||||
@@ -924,7 +938,8 @@ SwaggerUi.partials.signature = (function () {
|
|||||||
getParameterModelSignature: getParameterModelSignature,
|
getParameterModelSignature: getParameterModelSignature,
|
||||||
createParameterJSONSample: createParameterJSONSample,
|
createParameterJSONSample: createParameterJSONSample,
|
||||||
createSchemaXML: createSchemaXML,
|
createSchemaXML: createSchemaXML,
|
||||||
createXMLSample: createXMLSample
|
createXMLSample: createXMLSample,
|
||||||
|
getPrimitiveSignature: getPrimitiveSignature
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
{{#if_or sampleJSON sampleXML}}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<ul class="signature-nav">
|
<ul class="signature-nav">
|
||||||
<li><a class="description-link" href="#" data-sw-translate>Model</a></li>
|
<li><a class="description-link" href="#" data-sw-translate>Model</a></li>
|
||||||
@@ -25,3 +27,6 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{else}}
|
||||||
|
{{signature}}
|
||||||
|
{{/if_or}}
|
||||||
Reference in New Issue
Block a user