feat(samples): add support for uniqueItems keyword (#8893)

This change is specific to JSON Schema 2020-12
and OpenAPI 3.1.0.

Refs #8577
This commit is contained in:
Vladimír Gorej
2023-06-07 14:21:04 +02:00
committed by GitHub
parent 8a914926b3
commit 1114965782
2 changed files with 61 additions and 18 deletions

View File

@@ -1233,6 +1233,37 @@ describe("sampleFromSchema", () => {
expect(sampleFromSchema(definition)).toEqual(expected)
})
it("should handle maxItems", () => {
const definition = {
type: "array",
minItems: 4,
maxItems: 7,
items: {
type: "string",
},
}
const expected = sampleFromSchema(definition).length
expect(expected).toBeGreaterThanOrEqual(4)
expect(expected).toBeLessThanOrEqual(7)
})
it("should handle uniqueItems", () => {
const definition = {
type: "array",
minItems: 2,
uniqueItems: true,
items: {
type: "string",
},
}
const expected = ["string"]
expect(sampleFromSchema(definition)).toEqual(expected)
})
it("should handle minItems with example", () => {
const definition = {
type: "array",