Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ rules.set('Transform $defs to definitions', schema => {
})

rules.set('Transform const to singleton enum', schema => {
if (schema.const) {
if (schema.const !== undefined) {
schema.enum = [schema.const]
delete schema.const
}
Expand Down
11 changes: 11 additions & 0 deletions test/__snapshots__/test/test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9010,3 +9010,14 @@ Generated by [AVA](https://avajs.dev).
[k: string]: unknown;␊
}␊
`

## Normalize empty const to singleton enum

> Snapshot 1

`{␊
"id": "foo",␊
"enum": [␊
""␊
]␊
}`
Binary file modified test/__snapshots__/test/test.ts.snap
Binary file not shown.
11 changes: 11 additions & 0 deletions test/normalizer/emptyStringConstToEnum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Normalize empty const to singleton enum",
"in": {
"id": "foo",
"const": ""
},
"out": {
"id": "foo",
"enum": [""]
}
}