Skip to content

Commit

Permalink
swagger-api#1248 createXMLSample added object xml representation
Browse files Browse the repository at this point in the history
  • Loading branch information
bodnia committed Jan 13, 2016
1 parent fbb6ecf commit 3127f47
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
29 changes: 22 additions & 7 deletions swagger-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -26868,7 +26868,7 @@ SwaggerUi.partials.signature = (function () {
};
};

var createArray = function (name, items, xml) {
var createArrayXML = function (name, items, xml) {
var value;

if (!items) { return ''; }
Expand All @@ -26884,7 +26884,21 @@ SwaggerUi.partials.signature = (function () {
return value;
};

var createXMLSample = function (name, definition) {
function createObjectXML (name, properties, xml) {
var props;

if (!properties) { return ''; }

properties = properties || {};

props = _.map(properties, function (prop, key) {
return createXMLSample(key, prop);
}).join('');

return wrapTag(name, props);
}

function createXMLSample (name, definition) {
var primitivesMap = {
'string': {
'date': new Date(1).toISOString().split('T')[0],
Expand All @@ -26901,7 +26915,7 @@ SwaggerUi.partials.signature = (function () {
'default': true
}
};
var type = definition.type;
var type = definition.type || 'object';
var format = definition.format;
var xml = definition.xml || {};
var attributes = [];
Expand All @@ -26917,15 +26931,16 @@ SwaggerUi.partials.signature = (function () {

// Here are going to be else statements for Array and Object types
if (_.keys(primitivesMap).indexOf(type) !== -1) {
value = primitivesMap[type][format] || primitivesMap[type].default;

value = definition.example || primitivesMap[type][format] || primitivesMap[type].default;
return wrapTag(name, value, attributes);
} else if (type === 'array') {
return createArray(name, definition.items, xml);
return createArrayXML(name, definition.items, xml);
} else if (type === 'object') {
return createObjectXML(name, definition.properties, xml);
}

return '';
};
}

return {
getModelSignature: getModelSignature,
Expand Down
Loading

0 comments on commit 3127f47

Please sign in to comment.