Skip to content

Commit 3127f47

Browse files
committed
swagger-api#1248 createXMLSample added object xml representation
1 parent fbb6ecf commit 3127f47

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

swagger-ui.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26868,7 +26868,7 @@ SwaggerUi.partials.signature = (function () {
2686826868
};
2686926869
};
2687026870

26871-
var createArray = function (name, items, xml) {
26871+
var createArrayXML = function (name, items, xml) {
2687226872
var value;
2687326873

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

26887-
var createXMLSample = function (name, definition) {
26887+
function createObjectXML (name, properties, xml) {
26888+
var props;
26889+
26890+
if (!properties) { return ''; }
26891+
26892+
properties = properties || {};
26893+
26894+
props = _.map(properties, function (prop, key) {
26895+
return createXMLSample(key, prop);
26896+
}).join('');
26897+
26898+
return wrapTag(name, props);
26899+
}
26900+
26901+
function createXMLSample (name, definition) {
2688826902
var primitivesMap = {
2688926903
'string': {
2689026904
'date': new Date(1).toISOString().split('T')[0],
@@ -26901,7 +26915,7 @@ SwaggerUi.partials.signature = (function () {
2690126915
'default': true
2690226916
}
2690326917
};
26904-
var type = definition.type;
26918+
var type = definition.type || 'object';
2690526919
var format = definition.format;
2690626920
var xml = definition.xml || {};
2690726921
var attributes = [];
@@ -26917,15 +26931,16 @@ SwaggerUi.partials.signature = (function () {
2691726931

2691826932
// Here are going to be else statements for Array and Object types
2691926933
if (_.keys(primitivesMap).indexOf(type) !== -1) {
26920-
value = primitivesMap[type][format] || primitivesMap[type].default;
26921-
26934+
value = definition.example || primitivesMap[type][format] || primitivesMap[type].default;
2692226935
return wrapTag(name, value, attributes);
2692326936
} else if (type === 'array') {
26924-
return createArray(name, definition.items, xml);
26937+
return createArrayXML(name, definition.items, xml);
26938+
} else if (type === 'object') {
26939+
return createObjectXML(name, definition.properties, xml);
2692526940
}
2692626941

2692726942
return '';
26928-
};
26943+
}
2692926944

2693026945
return {
2693126946
getModelSignature: getModelSignature,

0 commit comments

Comments
 (0)