Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/core/plugins/samples/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
24 changes: 24 additions & 0 deletions test/core/plugins/samples/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down