#1248 createXMLSample added array
This commit is contained in:
22
dist/swagger-ui.js
vendored
22
dist/swagger-ui.js
vendored
@@ -26817,11 +26817,11 @@ SwaggerUi.partials.signature = (function () {
|
||||
|
||||
attributes = attrs.map(function (attr) {
|
||||
return ' ' + attr.name + '="' + attr.value + '"';
|
||||
});
|
||||
}).join('');
|
||||
|
||||
str = [
|
||||
'<', name,
|
||||
attributes.join(''),
|
||||
attributes,
|
||||
'>',
|
||||
value,
|
||||
'</', name, '>'
|
||||
@@ -26868,6 +26868,22 @@ SwaggerUi.partials.signature = (function () {
|
||||
};
|
||||
};
|
||||
|
||||
var createArray = function (name, items, xml) {
|
||||
var value;
|
||||
|
||||
if (!items) { return ''; }
|
||||
|
||||
value = createXMLSample(name, items) + createXMLSample(name, items);
|
||||
|
||||
xml = xml || {};
|
||||
|
||||
if (xml.wrapped) {
|
||||
value = wrapTag(name, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
var createXMLSample = function (name, definition) {
|
||||
var primitivesMap = {
|
||||
'string': {
|
||||
@@ -26904,6 +26920,8 @@ SwaggerUi.partials.signature = (function () {
|
||||
value = primitivesMap[type][format] || primitivesMap[type].default;
|
||||
|
||||
return wrapTag(name, value, attributes);
|
||||
} else if (type === 'array') {
|
||||
return createArray(name, definition.items, xml);
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
2
dist/swagger-ui.min.js
vendored
2
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -650,11 +650,11 @@ SwaggerUi.partials.signature = (function () {
|
||||
|
||||
attributes = attrs.map(function (attr) {
|
||||
return ' ' + attr.name + '="' + attr.value + '"';
|
||||
});
|
||||
}).join('');
|
||||
|
||||
str = [
|
||||
'<', name,
|
||||
attributes.join(''),
|
||||
attributes,
|
||||
'>',
|
||||
value,
|
||||
'</', name, '>'
|
||||
@@ -701,6 +701,22 @@ SwaggerUi.partials.signature = (function () {
|
||||
};
|
||||
};
|
||||
|
||||
var createArray = function (name, items, xml) {
|
||||
var value;
|
||||
|
||||
if (!items) { return ''; }
|
||||
|
||||
value = createXMLSample(name, items) + createXMLSample(name, items);
|
||||
|
||||
xml = xml || {};
|
||||
|
||||
if (xml.wrapped) {
|
||||
value = wrapTag(name, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
var createXMLSample = function (name, definition) {
|
||||
var primitivesMap = {
|
||||
'string': {
|
||||
@@ -737,6 +753,8 @@ SwaggerUi.partials.signature = (function () {
|
||||
value = primitivesMap[type][format] || primitivesMap[type].default;
|
||||
|
||||
return wrapTag(name, value, attributes);
|
||||
} else if (type === 'array') {
|
||||
return createArray(name, definition.items, xml);
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
@@ -114,5 +114,81 @@ describe('SwaggerUi.partials.signature tests', function () {
|
||||
expect(sut.createXMLSample(name, definition)).to.equal('<name xlmns="http://swagger.io/schema/sample">string</name>');
|
||||
});
|
||||
});
|
||||
|
||||
describe('array', function () {
|
||||
it('returns tag <tagname>string</tagname><tagname>string</tagname> when passing string items', function () {
|
||||
var expected = '<tagname>string</tagname><tagname>string</tagname>';
|
||||
var name = 'tagname';
|
||||
var definition = {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
}
|
||||
};
|
||||
|
||||
expect(sut.createXMLSample(name, definition)).to.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('array', function () {
|
||||
it('returns tag <animal>string</animal><animal>string</animal> when passing string items with name', function () {
|
||||
var expected = '<animal>string</animal><animal>string</animal>';
|
||||
var name = 'animals';
|
||||
var definition = {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
xml: {
|
||||
name: 'animal'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(sut.createXMLSample(name, definition)).to.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('array', function () {
|
||||
it('returns tag <animals><animal>string</animal><animal>string</animal></animals> when passing string items with name', function () {
|
||||
var expected = '<animals><animal>string</animal><animal>string</animal></animals>';
|
||||
var name = 'animals';
|
||||
var definition = {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
xml: {
|
||||
name: 'animal'
|
||||
}
|
||||
},
|
||||
xml: {
|
||||
wrapped: true
|
||||
}
|
||||
};
|
||||
|
||||
expect(sut.createXMLSample(name, definition)).to.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('array', function () {
|
||||
it('returns tag <aliens><animal>string</animal><animal>string</animal></aliens> when passing string items with name and {wrapped: true}', function () {
|
||||
var expected = '<aliens><animal>string</animal><animal>string</animal></aliens>';
|
||||
var name = 'animals';
|
||||
var definition = {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
xml: {
|
||||
name: 'animal'
|
||||
}
|
||||
},
|
||||
xml: {
|
||||
wrapped: true,
|
||||
name: 'aliens'
|
||||
}
|
||||
};
|
||||
|
||||
expect(sut.createXMLSample(name, definition)).to.equal(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user