Skip to content

Commit

Permalink
* fix(sample-gen): enum without type should be handled by sample-gen (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mathis-m authored Feb 11, 2021
1 parent fad81f8 commit 7ead9ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/plugins/samples/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const sampleFromSchemaGeneric = (schema, config={}, exampleOverride = und
type = "object"
} else if(items) {
type = "array"
} else if(!usePlainValue){
} else if(!usePlainValue && !schema.enum){
return
}
}
Expand Down
9 changes: 9 additions & 0 deletions test/unit/core/plugins/samples/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ describe("sampleFromSchema", () => {
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 () {
let definition = {
type: "object",
Expand Down

0 comments on commit 7ead9ba

Please sign in to comment.