Closed
Description
Since #290 the const
keyword is supported and acts as an alias for an enum
with one value. This is great but it does not work correctly for a const that contains an empty string. Example:
Input:
"foo": {
"const": ""
}
Expected output:
foo: ""
Actual output:
foo: {
[k: string]: unknown;
};
An enum containing a single value of an empty string does work as expected:
"foo": {
"enum": [
""
]
}
What use is a const with an empty string?
I use these for fields where the value is required and always a string but can be empty, for example an optional URL. Of course it should be nullable/optional really but this is a legacy application.
"url": {
"oneOf": [
{
"type": "string",
"format": "uri"
},
{
"enum": [
""
]
}
]
},
Metadata
Metadata
Assignees
Labels
No labels