提交 9a9cfdf1 编写于 作者: T Tim Macfarlane 提交者: kyle

improvement: omit deprecated fields in examples (via #4758)

上级 98fdb3e4
......@@ -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
}
......
......@@ -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",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册