Skip to content
11 changes: 11 additions & 0 deletions ark/json-schema/__tests__/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ contextualize(() => {
attest(tPatternString.allows("expression")).equals(true)
})

it("string enums", () => {
const enumKeys = ["keyOne", "keyTwo"]

const stringEnums = jsonSchemaToType({
type: "string",
enum: enumKeys
})

attest(stringEnums.expression).snap('"keyOne" | "keyTwo"')
})

it("minLength (0)", () => {
const schema = {
type: "string",
Expand Down
2 changes: 1 addition & 1 deletion ark/json-schema/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export const parseCommonJsonSchema = (
return type.unit(jsonSchema.const)
}

if ("enum" in jsonSchema) return type.enumerated(jsonSchema.enum)
if ("enum" in jsonSchema) return type.enumerated(...jsonSchema.enum)
}