Преглед на файлове

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

bubble
Tim Macfarlane преди 6 години
committed by kyle
родител
ревизия
9a9cfdf101
променени са 2 файла, в които са добавени 27 реда и са изтрити 0 реда
  1. +3
    -0
      src/core/plugins/samples/fn.js
  2. +24
    -0
      test/core/plugins/samples/fn.js

+ 3
- 0
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
}


+ 24
- 0
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",


Зареждане…
Отказ
Запис