Describe the bug.
The interpreter is currently, as far as I can tell, ignoring nullable properties on schemas, and therefor not updating isNullable on the resulting model.
My knowledge of the codebase is limtied, but the offending method appears to be interpretSchemaObject.
As a workaround, adding the following code to this function resolves the issue:
if (schema.nullable) {
model.addTypes('null');
}
Though, I am unsure if this is the correct way to do it, so I haven't opened a PR with it directly.
This affects versions ^4.0.0 and ^5.0.0
Expected behavior
Properties whose schema has nullable: true should generated the corresponding nullable model type.
Screenshots
Example of incorrect TypeScript model generation:
ServerEventsSubscriptionPayload:
type: object
properties:
# ...
visaToken:
type: string
nullable: true
title: ServerEventsSubscriptionPayload
export interface ServerEventsSubscriptionPayload {
// ...
visaToken?: string;
}
And after the above fix is applied:
export interface ServerEventsSubscriptionPayload {
// ...
visaToken?: string | null;
}
How to Reproduce
- Generate TypeScript models from an
asyncapi.yaml that includes a nullable: true property on a component.
- Observe missing
| null
🖥️ Device Information [optional]
- Operating System (OS): Windows 11
- Browser: N/A
- Browser Version: N/A
👀 Have you checked for similar open issues?
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue ?
Yes I am willing to submit a PR!
Describe the bug.
The interpreter is currently, as far as I can tell, ignoring
nullableproperties on schemas, and therefor not updatingisNullableon the resulting model.My knowledge of the codebase is limtied, but the offending method appears to be interpretSchemaObject.
As a workaround, adding the following code to this function resolves the issue:
Though, I am unsure if this is the correct way to do it, so I haven't opened a PR with it directly.
This affects versions
^4.0.0and^5.0.0Expected behavior
Properties whose schema has
nullable: trueshould generated the corresponding nullable model type.Screenshots
Example of incorrect TypeScript model generation:
And after the above fix is applied:
How to Reproduce
asyncapi.yamlthat includes anullable: trueproperty on a component.| null🖥️ Device Information [optional]
👀 Have you checked for similar open issues?
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue ?
Yes I am willing to submit a PR!