Skip to content

Commit cdc21f6

Browse files
committed
fix: dont immediately assume undefined if object with single enum null
1 parent edef49a commit cdc21f6

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

__tests__/fixtures/test1/models.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* WARN: Do not edit directly.
55
*
6-
* Generated on 2023-03-29T05:05:24.080Z
6+
* Generated on 2023-04-01T07:54:08.728Z
77
*
88
*/
99
export type Uuid = string;
@@ -130,19 +130,19 @@ export type BillingAccountCreateRequest = {
130130
country: BillingCountry;
131131
timeZone: TimeZone;
132132
currency: Currency;
133-
locale?: BillingLocale | undefined | null | undefined | null | undefined;
134-
purchaseOrder?: StringU8 | undefined | null | undefined | null | undefined;
135-
taxId?: StringU8 | undefined | null | undefined | null | undefined;
133+
locale?: BillingLocale | undefined | null | undefined;
134+
purchaseOrder?: StringU8 | undefined | null | undefined;
135+
taxId?: StringU8 | undefined | null | undefined;
136136
};
137137
export type BillingAccountUpdateRequest = {
138138
name?: Name | undefined;
139139
email?: Email | undefined;
140140
country?: BillingCountry | undefined;
141141
timeZone?: TimeZone | undefined;
142142
currency?: Currency | undefined;
143-
locale?: BillingLocale | undefined | null | undefined | null | undefined;
144-
purchaseOrder?: StringU8 | undefined | null | undefined | null | undefined;
145-
taxId?: StringU8 | undefined | null | undefined | null | undefined;
143+
locale?: BillingLocale | undefined | null | undefined;
144+
purchaseOrder?: StringU8 | undefined | null | undefined;
145+
taxId?: StringU8 | undefined | null | undefined;
146146
};
147147
export type BillingAccountList = BillingAccount[];
148148
export type BillingAccountPortalRequest = {
@@ -221,7 +221,7 @@ export type UpdateBillingSubscriptionRequest = {
221221
trialEndTime?: DateTime | undefined;
222222
};
223223
export type UpdateBillingSubscriptionPromoCodeRequest = {
224-
promoCode: StringU8 | null | undefined | null;
224+
promoCode: StringU8 | null;
225225
};
226226
export type BillingSubscriptionPromoCodeLongRunningOperationSuccess = {
227227
operationId: Uuid;

lib/process-schema.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,12 @@ export function schemaToType(
237237
}
238238

239239
if (schemaObject.type === 'object') {
240+
// type=object and enum null is common openapi nullable workaround
240241
if (schemaObject.enum?.every((e) => e === null)) {
241242
return {
242243
name,
243-
hasQuestionToken: true,
244-
type: maybeWithUndefined('null', true),
244+
hasQuestionToken: false,
245+
type: maybeWithUndefined('null', false),
245246
docs,
246247
};
247248
}

0 commit comments

Comments
 (0)