Merge branch 'bodnia-issue-1186'
This commit is contained in:
12
dist/css/print.css
vendored
12
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: #88F;
|
color: #8888ff;
|
||||||
}
|
}
|
||||||
.swagger-section pre .keyword,
|
.swagger-section pre .keyword,
|
||||||
.swagger-section pre .id,
|
.swagger-section pre .id,
|
||||||
@@ -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: #444;
|
color: #444444;
|
||||||
}
|
}
|
||||||
.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;
|
||||||
|
|||||||
12
dist/css/screen.css
vendored
12
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: #88F;
|
color: #8888ff;
|
||||||
}
|
}
|
||||||
.swagger-section pre .keyword,
|
.swagger-section pre .keyword,
|
||||||
.swagger-section pre .id,
|
.swagger-section pre .id,
|
||||||
@@ -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: #444;
|
color: #444444;
|
||||||
}
|
}
|
||||||
.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;
|
||||||
|
|||||||
1295
dist/swagger-ui.js
vendored
1295
dist/swagger-ui.js
vendored
File diff suppressed because one or more lines are too long
22
dist/swagger-ui.min.js
vendored
22
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: #88F;
|
color: #8888ff;
|
||||||
}
|
}
|
||||||
.swagger-section pre .keyword,
|
.swagger-section pre .keyword,
|
||||||
.swagger-section pre .id,
|
.swagger-section pre .id,
|
||||||
@@ -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: #444;
|
color: #444444;
|
||||||
}
|
}
|
||||||
.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;
|
||||||
|
|||||||
@@ -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: #88F;
|
color: #8888ff;
|
||||||
}
|
}
|
||||||
.swagger-section pre .keyword,
|
.swagger-section pre .keyword,
|
||||||
.swagger-section pre .id,
|
.swagger-section pre .id,
|
||||||
@@ -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: #444;
|
color: #444444;
|
||||||
}
|
}
|
||||||
.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;
|
||||||
|
|||||||
@@ -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.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;
|
||||||
@@ -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 @@
|
|||||||
|
{{#ifCond 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}}
|
||||||
|
{{/ifCond}}
|
||||||
@@ -650,4 +650,39 @@ describe('SwaggerUi.partials.signature tests', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('method getPrimitiveSignature', function () {
|
||||||
|
it('returns warning message when type is object', function () {
|
||||||
|
expect(sut.getPrimitiveSignature({type: 'object'})).to.equal('Object is not a primitive');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns array with items.format when passing array', function () {
|
||||||
|
var schema = {
|
||||||
|
type: 'array',
|
||||||
|
items: {
|
||||||
|
format: 'format',
|
||||||
|
type: 'type'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(sut.getPrimitiveSignature(schema)).to.equal('Array[format]');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns array with items.type when passing array without items.format', function () {
|
||||||
|
var schema = {
|
||||||
|
type: 'array',
|
||||||
|
items: {
|
||||||
|
type: 'type'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(sut.getPrimitiveSignature(schema)).to.equal('Array[type]');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns format of primitive', function () {
|
||||||
|
expect(sut.getPrimitiveSignature({type: 'type', format: 'format'})).to.equal('format');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns type of primitive if format is not passed', function () {
|
||||||
|
expect(sut.getPrimitiveSignature({type: 'type'})).to.equal('type');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user