From 558a615e9ddc5a7ef7336afad775c0ed7a318994 Mon Sep 17 00:00:00 2001 From: Elliot Ball Date: Wed, 4 Oct 2023 13:17:14 +0100 Subject: [PATCH 1/2] remove enum sorting --- typescript-json-schema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript-json-schema.ts b/typescript-json-schema.ts index 45876994..5e43a031 100644 --- a/typescript-json-schema.ts +++ b/typescript-json-schema.ts @@ -926,7 +926,7 @@ export class JsonSchemaGenerator { if (enumValues.length > 0) { if (enumValues.length > 1) { - definition.enum = enumValues.sort(); + definition.enum = enumValues; } else { definition.const = enumValues[0]; } From ebfb4fc281fafd156162784d52b789bebb2fd754 Mon Sep 17 00:00:00 2001 From: Elliot Ball Date: Wed, 4 Oct 2023 13:29:35 +0100 Subject: [PATCH 2/2] fix enum tests by updating the order of enums in assertions --- test/programs/enums-compiled-compute/schema.json | 4 ++-- test/programs/enums-mixed/schema.json | 4 ++-- test/programs/enums-number-initialized/schema.json | 4 ++-- test/programs/enums-string/schema.json | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/programs/enums-compiled-compute/schema.json b/test/programs/enums-compiled-compute/schema.json index 3217bf03..5e9df0b4 100644 --- a/test/programs/enums-compiled-compute/schema.json +++ b/test/programs/enums-compiled-compute/schema.json @@ -1,10 +1,10 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "enum": [ - 1, 2, 4, - 6 + 6, + 1 ], "type": "number" } diff --git a/test/programs/enums-mixed/schema.json b/test/programs/enums-mixed/schema.json index c6db8fb5..3b91d6a3 100644 --- a/test/programs/enums-mixed/schema.json +++ b/test/programs/enums-mixed/schema.json @@ -6,9 +6,9 @@ "enum": [ 0, 1, - null, + true, "str", - true + null ], "type": [ "number", diff --git a/test/programs/enums-number-initialized/schema.json b/test/programs/enums-number-initialized/schema.json index 480b2df6..01c66c33 100644 --- a/test/programs/enums-number-initialized/schema.json +++ b/test/programs/enums-number-initialized/schema.json @@ -1,10 +1,10 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "enum": [ - 1, 10, 11, - 12 + 12, + 1 ], "type": "number" } diff --git a/test/programs/enums-string/schema.json b/test/programs/enums-string/schema.json index e3b07564..1f7e1e67 100644 --- a/test/programs/enums-string/schema.json +++ b/test/programs/enums-string/schema.json @@ -4,9 +4,9 @@ "definitions": { "Enum": { "enum": [ - "123", "x", - "y" + "y", + "123" ], "type": "string" }