diff --git a/src/core/plugins/samples/fn.js b/src/core/plugins/samples/fn.js index 9dd9b9ea2d8..b8d7da6208c 100644 --- a/src/core/plugins/samples/fn.js +++ b/src/core/plugins/samples/fn.js @@ -307,12 +307,8 @@ export const sampleFromSchemaGeneric = (schema, config={}, exampleOverride = und if (schema && props[propName] && props[propName].writeOnly && !includeWriteOnly) { continue } - if (schema && props[propName] && props[propName].xml && props[propName].xml.attribute && !(example && example[propName])) { - _attr[props[propName].xml.name || propName] = sample[propName] - continue - } if (schema && props[propName] && props[propName].xml && props[propName].xml.attribute) { - _attr[props[propName].xml.name || propName] = example[propName] + _attr[props[propName].xml.name || propName] = sample[propName] continue } addPropertyToResult(propName, sample[propName]) diff --git a/test/unit/core/plugins/samples/fn.js b/test/unit/core/plugins/samples/fn.js index c519c187268..c95f555b575 100644 --- a/test/unit/core/plugins/samples/fn.js +++ b/test/unit/core/plugins/samples/fn.js @@ -1774,6 +1774,25 @@ describe("createXMLExample", function () { expect(sut(definition, {}, expected)).toEqual(expected) }) + it("should use exampleOverride for attr too", () => { + let expected = "\n\n" + let definition = { + type: "object", + properties: { + test: { + type: "string", + xml: { + attribute: true + } + } + }, + xml: { + name: "aliens" + } + } + + expect(sut(definition, {}, { test: "probe" })).toEqual(expected) + }) }) })