We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I've noticed an issue with the latest update to support type arrays per 3.1.0 spec (thanks a ton for adding that!)
However, I've noticed if the type is
type: - array - "null"
or
type: - object - "null"
The null is not included in the final type. For example, this type from my spec:
title: LoadBalancerLatestTelemetryController type: object required: - time - controller properties: time: $ref: ../../../../DateTime.yml controller: $ref: ../../../../Identifier.yml instances: type: - array - "null" items: $ref: ./LoadBalancerLatestTelemetryInstance.yml
generated the following code:
export type LoadBalancerLatestTelemetryController = { time: DateTime; controller: Identifier; instances?: LoadBalancerLatestTelemetryInstance[]; };
or, in the case of object, this:
title: PromoCode type: object description: A billing promo code. required: - code - credit - expires - state properties: code: type: string description: The promo "code". credit: type: - object - "null" description: The amount of credit the promo code offers. additionalProperties: type: object properties: amount: "$ref": "./BillingAmount.yml" expires: "$ref": "../DateTime.yml" state: title: PromoCodeState allOf: - required: - current properties: current: description: The current state of the promo code. type: string enum: - live - deleted - "$ref": "../State.yml"
generates this:
export type PromoCode = { /** The promo "code". */ code: string; /** The amount of credit the promo code offers. */ credit: { [key: string]: { amount?: BillingAmount; expires?: DateTime; }; }; state: { /** The current state of the promo code. */ current: "live" | "deleted"; } & State; };
Every other type seems to work, and using anyOf seems to work as well:
anyOf
property: anyOf: - $ref: xyz.yml - type: "null"
So it just seems to be these two cases that I've found so far. Any help is appreciated!
The text was updated successfully, but these errors were encountered:
Hi @mattoni, thank for reporting this 👍
To be clear, the expected outcome for your first example would be
export type LoadBalancerLatestTelemetryController = { time: DateTime; controller: Identifier; instances?: LoadBalancerLatestTelemetryInstance[]; } | null;
right?
Sorry, something went wrong.
No, it'd be
export type LoadBalancerLatestTelemetryController = { time: DateTime; controller: Identifier; instances?: LoadBalancerLatestTelemetryInstance[] | null; }
where the instances field is also nullable.
my bad, yeah - that makes sense!
No branches or pull requests
I've noticed an issue with the latest update to support type arrays per 3.1.0 spec (thanks a ton for adding that!)
However, I've noticed if the type is
or
The null is not included in the final type. For example, this type from my spec:
generated the following code:
or, in the case of object, this:
generates this:
Every other type seems to work, and using
anyOf
seems to work as well:So it just seems to be these two cases that I've found so far. Any help is appreciated!
The text was updated successfully, but these errors were encountered: