#1248 implemented display property as attribute
This commit is contained in:
27
dist/swagger-ui.js
vendored
27
dist/swagger-ui.js
vendored
@@ -21089,22 +21089,27 @@ SwaggerUi.partials.signature = (function () {
|
||||
};
|
||||
var type = definition.type;
|
||||
var format = definition.format;
|
||||
var namespace = getNamespace(definition.xml);
|
||||
var xml = definition.xml || {};
|
||||
var namespace = getNamespace(xml);
|
||||
var attributes = [];
|
||||
var value;
|
||||
|
||||
if (_.keys(primitivesMap).indexOf(type) < 0) { return getErrorMessage(); }
|
||||
|
||||
if (namespace) {
|
||||
attributes.push(namespace);
|
||||
}
|
||||
|
||||
if (_.isArray(definition.enum)){
|
||||
value = definition.enum[0];
|
||||
} else {
|
||||
value = definition.example || primitivesMap[type][format] || primitivesMap[type].default;
|
||||
}
|
||||
|
||||
if (xml.attribute) {
|
||||
return {name: name, value: value};
|
||||
}
|
||||
|
||||
if (namespace) {
|
||||
attributes.push(namespace);
|
||||
}
|
||||
|
||||
return wrapTag(name, value, attributes);
|
||||
};
|
||||
|
||||
@@ -21129,9 +21134,19 @@ SwaggerUi.partials.signature = (function () {
|
||||
properties = properties || {};
|
||||
|
||||
serializedProperties = _.map(properties, function (prop, key) {
|
||||
var xml, result;
|
||||
|
||||
if (isParam && prop.readOnly) { return ''; }
|
||||
|
||||
return createSchemaXML(key, prop, models);
|
||||
xml = prop.xml || {};
|
||||
result = createSchemaXML(key, prop, models);
|
||||
|
||||
if (xml.attribute) {
|
||||
attrs.push(result);
|
||||
return '';
|
||||
}
|
||||
|
||||
return result;
|
||||
}).join('');
|
||||
|
||||
if (additionalProperties) {
|
||||
|
||||
4
dist/swagger-ui.min.js
vendored
4
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -753,22 +753,27 @@ SwaggerUi.partials.signature = (function () {
|
||||
};
|
||||
var type = definition.type;
|
||||
var format = definition.format;
|
||||
var namespace = getNamespace(definition.xml);
|
||||
var xml = definition.xml || {};
|
||||
var namespace = getNamespace(xml);
|
||||
var attributes = [];
|
||||
var value;
|
||||
|
||||
if (_.keys(primitivesMap).indexOf(type) < 0) { return getErrorMessage(); }
|
||||
|
||||
if (namespace) {
|
||||
attributes.push(namespace);
|
||||
}
|
||||
|
||||
if (_.isArray(definition.enum)){
|
||||
value = definition.enum[0];
|
||||
} else {
|
||||
value = definition.example || primitivesMap[type][format] || primitivesMap[type].default;
|
||||
}
|
||||
|
||||
if (xml.attribute) {
|
||||
return {name: name, value: value};
|
||||
}
|
||||
|
||||
if (namespace) {
|
||||
attributes.push(namespace);
|
||||
}
|
||||
|
||||
return wrapTag(name, value, attributes);
|
||||
};
|
||||
|
||||
@@ -793,9 +798,19 @@ SwaggerUi.partials.signature = (function () {
|
||||
properties = properties || {};
|
||||
|
||||
serializedProperties = _.map(properties, function (prop, key) {
|
||||
var xml, result;
|
||||
|
||||
if (isParam && prop.readOnly) { return ''; }
|
||||
|
||||
return createSchemaXML(key, prop, models);
|
||||
xml = prop.xml || {};
|
||||
result = createSchemaXML(key, prop, models);
|
||||
|
||||
if (xml.attribute) {
|
||||
attrs.push(result);
|
||||
return '';
|
||||
}
|
||||
|
||||
return result;
|
||||
}).join('');
|
||||
|
||||
if (additionalProperties) {
|
||||
|
||||
@@ -442,6 +442,32 @@ describe('SwaggerUi.partials.signature tests', function () {
|
||||
|
||||
expect(sut.createSchemaXML(name, definition, models, true)).to.equal(expected);
|
||||
});
|
||||
|
||||
it('returns object with passed parameter as attribute', function () {
|
||||
var expected = '<animals id="1">' +
|
||||
'<dog>string</dog>' +
|
||||
'</animals>';
|
||||
var name = 'animals';
|
||||
var definition = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'integer',
|
||||
xml: {
|
||||
attribute: true
|
||||
}
|
||||
},
|
||||
dog: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
xml: {
|
||||
name: 'animals'
|
||||
}
|
||||
};
|
||||
|
||||
expect(sut.createSchemaXML(name, definition, models, true)).to.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('schema is in definitions', function () {
|
||||
|
||||
Reference in New Issue
Block a user