diff --git a/.node-version b/.node-version new file mode 100644 index 000000000..60d3b2f4a --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +15 diff --git a/src/utils.ts b/src/utils.ts index 51defff12..4f7468e91 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -31,7 +31,7 @@ export function nodeType(obj: any): SchemaObjectType | undefined { } // enum - if (Array.isArray(obj.enum)) { + if (Array.isArray(obj.enum) && obj.enum.length) { return "enum"; } diff --git a/tests/schema.test.ts b/tests/schema.test.ts index a29c8b7c8..5740f36d4 100644 --- a/tests/schema.test.ts +++ b/tests/schema.test.ts @@ -211,6 +211,13 @@ describe("SchemaObject", () => { "string"?: (('Totoro') | (2) | (false)) | null; }`); + + expect(transform({ properties: { string: { type: "string", enum: [] } }, type: "object" })).toBe( + `{ +"string"?: string; + +}` + ); }); it("$ref", () => {