Add writeOnly logic

This commit is contained in:
Kyle Shockey
2017-08-03 17:13:38 -07:00
parent 8633372270
commit 5e96821c05

View File

@@ -96,7 +96,7 @@ export const inferSchema = (thing) => {
export const sampleXmlFromSchema = (schema, config={}) => { export const sampleXmlFromSchema = (schema, config={}) => {
let objectifySchema = objectify(schema) let objectifySchema = objectify(schema)
let { type, properties, additionalProperties, items, example } = objectifySchema let { type, properties, additionalProperties, items, example } = objectifySchema
let { includeReadOnly } = config let { includeReadOnly, includeWriteOnly } = config
let defaultValue = objectifySchema.default let defaultValue = objectifySchema.default
let res = {} let res = {}
let _attr = {} let _attr = {}
@@ -177,7 +177,13 @@ export const sampleXmlFromSchema = (schema, config={}) => {
example = example || {} example = example || {}
for (let propName in props) { for (let propName in props) {
if ( !props[propName].readOnly || includeReadOnly ) { if ( props[propName].readOnly && !includeReadOnly ) {
continue
}
if ( props[propName].writeOnly && !includeWriteOnly ) {
continue
}
props[propName].xml = props[propName].xml || {} props[propName].xml = props[propName].xml || {}
if (props[propName].xml.attribute) { if (props[propName].xml.attribute) {
@@ -199,7 +205,6 @@ export const sampleXmlFromSchema = (schema, config={}) => {
} }
} }
}
if (additionalProperties === true) { if (additionalProperties === true) {
res[displayName].push({additionalProp: "Anything can be here"}) res[displayName].push({additionalProp: "Anything can be here"})