Open
Description
Description
When a JSON API spec has "nullable": true
for an empty object, the resulting TS type does not include null
.
Reproduction
Copy the following into a JSON API spec:
"NullableEmptyObject": {
"nullable": true,
"properties": {},
"title": "NullableEmptyObject",
"type": "object"
},
"NullableObject": {
"nullable": true,
"properties": {
"name": {
"type": "string"
}
},
"title": "NullableObject",
"type": "object"
},
"NullableString": {
"nullable": true,
"title": "NullableString",
"type": "string"
},
The generated TS types are
/** NullableEmptyObject */
NullableEmptyObject: Record<string, never>;
/** NullableObject */
NullableObject: {
name?: string;
} | null;
/** NullableString */
NullableString: string | null;
Expected result
NullableEmptyObject
should be typed as Record<string, never> | null
.
Checklist
- My OpenAPI schema passes the Redocly validator (
npx @redocly/cli@latest lint
) - I’m willing to open a PR (see CONTRIBUTING.md)
I could open a PR in a few weeks, but I'm not able to do so right now!
Metadata
Metadata
Assignees
Type
Projects
Status
No status