#1248 createXMLSample Added handling readyOnly params
This commit is contained in:
@@ -58,7 +58,7 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
|
||||
|
||||
var signatureModel = {
|
||||
sampleJSON: SwaggerUi.partials.signature.createParameterJSONSample(modelType, modelDefinitions),
|
||||
sampleXML: isXML ? SwaggerUi.partials.signature.createXMLSample(schema, modelDefinitions) : false,
|
||||
sampleXML: isXML ? SwaggerUi.partials.signature.createXMLSample(schema, modelDefinitions, true) : false,
|
||||
isParam: true,
|
||||
signature: SwaggerUi.partials.signature.getParameterModelSignature(modelType, modelDefinitions),
|
||||
defaultRendering: this.model.defaultRendering
|
||||
|
||||
@@ -776,6 +776,7 @@ SwaggerUi.partials.signature = (function () {
|
||||
var name = descriptor.name;
|
||||
var definition = descriptor.definition;
|
||||
var models = descriptor.models;
|
||||
var isParam = descriptor.isParam;
|
||||
var serializedProperties;
|
||||
var attrs = [];
|
||||
var properties = definition.properties;
|
||||
@@ -792,6 +793,8 @@ SwaggerUi.partials.signature = (function () {
|
||||
properties = properties || {};
|
||||
|
||||
serializedProperties = _.map(properties, function (prop, key) {
|
||||
if (isParam && prop.readOnly) { return ''; }
|
||||
|
||||
return createSchemaXML(key, prop, models);
|
||||
}).join('');
|
||||
|
||||
@@ -806,10 +809,10 @@ SwaggerUi.partials.signature = (function () {
|
||||
return '<!-- invalid XML -->';
|
||||
}
|
||||
|
||||
function createSchemaXML (name, definition, models) {
|
||||
function createSchemaXML (name, definition, models, isParam) {
|
||||
var $ref = definition.$ref;
|
||||
var descriptor = _.isString($ref) ? getDescriptorByRef($ref, models)
|
||||
: getDescriptor(name, definition, models);
|
||||
: getDescriptor(name, definition, models, isParam);
|
||||
|
||||
if (!descriptor) {
|
||||
return getErrorMessage();
|
||||
@@ -825,7 +828,7 @@ SwaggerUi.partials.signature = (function () {
|
||||
}
|
||||
}
|
||||
|
||||
function Descriptor (name, type, definition, models) {
|
||||
function Descriptor (name, type, definition, models, isParam) {
|
||||
if (arguments.length < 4) {
|
||||
throw new Error();
|
||||
}
|
||||
@@ -834,6 +837,7 @@ SwaggerUi.partials.signature = (function () {
|
||||
this.definition = definition;
|
||||
this.models = models;
|
||||
this.type = type;
|
||||
this.isParam = isParam;
|
||||
}
|
||||
|
||||
function getDescriptorByRef($ref, models) {
|
||||
@@ -849,7 +853,7 @@ SwaggerUi.partials.signature = (function () {
|
||||
return new Descriptor (name, type, model.definition, models);
|
||||
}
|
||||
|
||||
function getDescriptor (name, definition, models){
|
||||
function getDescriptor (name, definition, models, isParam){
|
||||
var type = definition.type || 'object';
|
||||
var xml = definition.xml || {};
|
||||
|
||||
@@ -859,13 +863,13 @@ SwaggerUi.partials.signature = (function () {
|
||||
|
||||
name = getName(name, xml);
|
||||
|
||||
return new Descriptor(name, type, definition, models);
|
||||
return new Descriptor(name, type, definition, models,isParam);
|
||||
}
|
||||
|
||||
function createXMLSample (definition, models) {
|
||||
function createXMLSample (definition, models, isParam) {
|
||||
var prolog = '<?xml version="1.0"?>';
|
||||
|
||||
return formatXml(prolog + createSchemaXML('', definition, models));
|
||||
return formatXml(prolog + createSchemaXML('', definition, models, isParam));
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user