diff --git a/src/core/plugins/samples/fn.js b/src/core/plugins/samples/fn.js index 83b6c83fc542489bda347140bf18d8d88a3b461b..b6a4ded4600d3d7b32936d01bc7961d903006f58 100644 --- a/src/core/plugins/samples/fn.js +++ b/src/core/plugins/samples/fn.js @@ -52,6 +52,9 @@ export const sampleFromSchema = (schema, config={}) => { let props = objectify(properties) let obj = {} for (var name in props) { + if ( props[name] && props[name].deprecated ) { + continue + } if ( props[name] && props[name].readOnly && !includeReadOnly ) { continue } diff --git a/test/core/plugins/samples/fn.js b/test/core/plugins/samples/fn.js index 609ba24bad682b6bc186466b887f9f5047fe2c53..697da7f1fcd5527bb5ca5c52bf594b0aa412f9f8 100644 --- a/test/core/plugins/samples/fn.js +++ b/test/core/plugins/samples/fn.js @@ -79,6 +79,30 @@ describe("sampleFromSchema", function() { expect(sampleFromSchema(definition, { includeReadOnly: true })).toEqual(expected) }) + it("returns object without deprecated fields for parameter", function () { + var definition = { + type: "object", + properties: { + id: { + type: "integer" + }, + deprecatedProperty: { + deprecated: true, + type: "string" + } + }, + xml: { + name: "animals" + } + } + + var expected = { + id: 0 + } + + expect(sampleFromSchema(definition)).toEqual(expected) + }) + it("returns object without writeonly fields for parameter", function () { var definition = { type: "object",