improvement: omit deprecated fields in examples (via #4758)
This commit is contained in:
@@ -52,6 +52,9 @@ export const sampleFromSchema = (schema, config={}) => {
|
|||||||
let props = objectify(properties)
|
let props = objectify(properties)
|
||||||
let obj = {}
|
let obj = {}
|
||||||
for (var name in props) {
|
for (var name in props) {
|
||||||
|
if ( props[name] && props[name].deprecated ) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if ( props[name] && props[name].readOnly && !includeReadOnly ) {
|
if ( props[name] && props[name].readOnly && !includeReadOnly ) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,30 @@ describe("sampleFromSchema", function() {
|
|||||||
expect(sampleFromSchema(definition, { includeReadOnly: true })).toEqual(expected)
|
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 () {
|
it("returns object without writeonly fields for parameter", function () {
|
||||||
var definition = {
|
var definition = {
|
||||||
type: "object",
|
type: "object",
|
||||||
|
|||||||
Reference in New Issue
Block a user