Skip to content

Commit

Permalink
Remove enum sorting (#576)
Browse files Browse the repository at this point in the history
* remove enum sorting

* fix enum tests by updating the order of enums in assertions
  • Loading branch information
Elliot-Ball-Tray committed Oct 4, 2023
1 parent 655d774 commit c55b419
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions test/programs/enums-compiled-compute/schema.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"enum": [
1,
2,
4,
6
6,
1
],
"type": "number"
}
Expand Down
4 changes: 2 additions & 2 deletions test/programs/enums-mixed/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"enum": [
0,
1,
null,
true,
"str",
true
null
],
"type": [
"number",
Expand Down
4 changes: 2 additions & 2 deletions test/programs/enums-number-initialized/schema.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"enum": [
1,
10,
11,
12
12,
1
],
"type": "number"
}
Expand Down
4 changes: 2 additions & 2 deletions test/programs/enums-string/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"definitions": {
"Enum": {
"enum": [
"123",
"x",
"y"
"y",
"123"
],
"type": "string"
}
Expand Down
2 changes: 1 addition & 1 deletion typescript-json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit c55b419

Please sign in to comment.