Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum without type should be handled by sample-gen #6912

Merged
merged 3 commits into from Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/plugins/samples/fn.js
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
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