* fix(sample-gen): enum without type should be handled by sample-gen (#6912)
This commit is contained in:
@@ -133,7 +133,7 @@ export const sampleFromSchemaGeneric = (schema, config={}, exampleOverride = und
|
|||||||
type = "object"
|
type = "object"
|
||||||
} else if(items) {
|
} else if(items) {
|
||||||
type = "array"
|
type = "array"
|
||||||
} else if(!usePlainValue){
|
} else if(!usePlainValue && !schema.enum){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,15 @@ describe("sampleFromSchema", () => {
|
|||||||
expect(sampleFromSchema(definition, { includeReadOnly: false })).toEqual(expected)
|
expect(sampleFromSchema(definition, { includeReadOnly: false })).toEqual(expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should return first enum value if only enum is provided", function () {
|
||||||
|
let definition = fromJS({
|
||||||
|
enum: ["probe"]
|
||||||
|
})
|
||||||
|
|
||||||
|
let expected = "probe"
|
||||||
|
expect(sampleFromSchema(definition, { includeReadOnly: false })).toEqual(expected)
|
||||||
|
})
|
||||||
|
|
||||||
it("combine first oneOf or anyOf with schema's definitions", function () {
|
it("combine first oneOf or anyOf with schema's definitions", function () {
|
||||||
let definition = {
|
let definition = {
|
||||||
type: "object",
|
type: "object",
|
||||||
|
|||||||
Reference in New Issue
Block a user