#1248 createXMLSample added message about additional properties

This commit is contained in:
Anna Bodnia
2016-01-14 20:53:30 +02:00
parent 9543ea4671
commit c1f4814281
3 changed files with 41 additions and 22 deletions

22
dist/swagger-ui.js vendored
View File

@@ -26868,8 +26868,10 @@ SwaggerUi.partials.signature = (function () {
}; };
}; };
var createArrayXML = function (name, items, xml, models) { var createArrayXML = function (name, definition, models) {
var value; var value;
var items = definition.items;
var xml = definition.xml || {};
if (!items) { return ''; } if (!items) { return ''; }
@@ -26935,16 +26937,19 @@ SwaggerUi.partials.signature = (function () {
return wrapTag(name, value, attributes); return wrapTag(name, value, attributes);
}; };
function createObjectXML (name, properties, xml, models) { function createObjectXML (name, definition, models) {
var props; var props;
var attrs = []; var attrs = [];
var properties = definition.properties;
var additionalProperties = definition.additionalProperties;
var xml = definition.xml;
var namespace = getNamespace(xml); var namespace = getNamespace(xml);
if (namespace) { if (namespace) {
attrs.push(namespace); attrs.push(namespace);
} }
if (!properties) { return ''; } if (!properties && !additionalProperties) { return ''; }
properties = properties || {}; properties = properties || {};
@@ -26952,12 +26957,17 @@ SwaggerUi.partials.signature = (function () {
return createXMLSample(key, prop, models); return createXMLSample(key, prop, models);
}).join(''); }).join('');
return wrapTag(name, props); if (additionalProperties) {
props += '<!-- additional elements allowed -->';
}
return wrapTag(name, props, attrs);
} }
function createXMLSample (name, definition, models) { function createXMLSample (name, definition, models) {
var type, xml, $ref; var type, xml, $ref;
// allow ingnoring 'name' parameter
if (arguments.length === 2) { if (arguments.length === 2) {
models = arguments[1]; models = arguments[1];
definition = arguments[0]; definition = arguments[0];
@@ -26975,9 +26985,9 @@ SwaggerUi.partials.signature = (function () {
name = getName(name, xml); name = getName(name, xml);
if (type === 'array') { if (type === 'array') {
return createArrayXML(name, definition.items, xml, models); return createArrayXML(name, definition, models);
} else if (type === 'object') { } else if (type === 'object') {
return createObjectXML(name, definition.properties, xml, models); return createObjectXML(name, definition, models);
} else { } else {
return createPrimitiveXML(name, definition); return createPrimitiveXML(name, definition);
} }

File diff suppressed because one or more lines are too long

View File

@@ -701,8 +701,10 @@ SwaggerUi.partials.signature = (function () {
}; };
}; };
var createArrayXML = function (name, items, xml, models) { var createArrayXML = function (name, definition, models) {
var value; var value;
var items = definition.items;
var xml = definition.xml || {};
if (!items) { return ''; } if (!items) { return ''; }
@@ -768,16 +770,19 @@ SwaggerUi.partials.signature = (function () {
return wrapTag(name, value, attributes); return wrapTag(name, value, attributes);
}; };
function createObjectXML (name, properties, xml, models) { function createObjectXML (name, definition, models) {
var props; var props;
var attrs = []; var attrs = [];
var properties = definition.properties;
var additionalProperties = definition.additionalProperties;
var xml = definition.xml;
var namespace = getNamespace(xml); var namespace = getNamespace(xml);
if (namespace) { if (namespace) {
attrs.push(namespace); attrs.push(namespace);
} }
if (!properties) { return ''; } if (!properties && !additionalProperties) { return ''; }
properties = properties || {}; properties = properties || {};
@@ -785,7 +790,11 @@ SwaggerUi.partials.signature = (function () {
return createXMLSample(key, prop, models); return createXMLSample(key, prop, models);
}).join(''); }).join('');
return wrapTag(name, props); if (additionalProperties) {
props += '<!-- additional elements allowed -->';
}
return wrapTag(name, props, attrs);
} }
function createXMLSample (name, definition, models) { function createXMLSample (name, definition, models) {
@@ -809,9 +818,9 @@ SwaggerUi.partials.signature = (function () {
name = getName(name, xml); name = getName(name, xml);
if (type === 'array') { if (type === 'array') {
return createArrayXML(name, definition.items, xml, models); return createArrayXML(name, definition, models);
} else if (type === 'object') { } else if (type === 'object') {
return createObjectXML(name, definition.properties, xml, models); return createObjectXML(name, definition, models);
} else { } else {
return createPrimitiveXML(name, definition); return createPrimitiveXML(name, definition);
} }