Skip to content

Commit 9e4f61c

Browse files
fix(openapi-typescript): handle nullable schemas (#2059)
* fix(openapi-typescript): handle nullable schemas * chore(examples): regenerate after nullable handling fix
1 parent d2de5c7 commit 9e4f61c

9 files changed

+281
-167
lines changed
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-typescript": minor
3+
---
4+
5+
Allow all types except UNKNOWN to be nullable

packages/openapi-typescript/examples/digital-ocean-api.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -12439,7 +12439,7 @@ export interface components {
1243912439
* @description The Droplet that the floating IP has been assigned to. When you query a floating IP, if it is assigned to a Droplet, the entire Droplet object will be returned. If it is not assigned, the value will be null.
1244012440
* @example null
1244112441
*/
12442-
droplet?: Record<string, never> | components["schemas"]["droplet"];
12442+
droplet?: (Record<string, never> | null) | components["schemas"]["droplet"];
1244312443
/**
1244412444
* @description A boolean value indicating whether or not the floating IP has pending actions preventing new ones from being submitted.
1244512445
* @example true
@@ -12780,7 +12780,7 @@ export interface components {
1278012780
* @description An object of key/value mappings specifying labels to apply to all nodes in a pool. Labels will automatically be applied to all existing nodes and any subsequent nodes added to the pool. Note that when a label is removed, it is not deleted from the nodes in the pool.
1278112781
* @example null
1278212782
*/
12783-
labels?: Record<string, never>;
12783+
labels?: Record<string, never> | null;
1278412784
/** @description An array of taints to apply to all nodes in a pool. Taints will automatically be applied to all existing nodes and any subsequent nodes added to the pool. When a taint is removed, it is deleted from all nodes in the pool. */
1278512785
taints?: components["schemas"]["kubernetes_node_pool_taint"][];
1278612786
/**
@@ -14339,7 +14339,7 @@ export interface components {
1433914339
* @description The Droplet that the reserved IP has been assigned to. When you query a reserved IP, if it is assigned to a Droplet, the entire Droplet object will be returned. If it is not assigned, the value will be null.
1434014340
* @example null
1434114341
*/
14342-
droplet?: Record<string, never> | components["schemas"]["droplet"];
14342+
droplet?: (Record<string, never> | null) | components["schemas"]["droplet"];
1434314343
/**
1434414344
* @description A boolean value indicating whether or not the reserved IP has pending actions preventing new ones from being submitted.
1434514345
* @example true

packages/openapi-typescript/examples/github-api-export-type-immutable.ts

+30-30
Original file line numberDiff line numberDiff line change
@@ -41164,7 +41164,7 @@ export type components = {
4116441164
readonly created_at: string;
4116541165
/** @description The time that the alert was dismissed in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ`. */
4116641166
readonly dismissed_at: string | null;
41167-
readonly dismissed_by: Record<string, never>;
41167+
readonly dismissed_by: Record<string, never> | null;
4116841168
/** @description The reason for dismissing or closing the alert. Can be one of: `false positive`, `won't fix`, and `used in tests`. */
4116941169
readonly dismissed_reason: string | null;
4117041170
/**
@@ -42189,7 +42189,7 @@ export type components = {
4218942189
readonly display_title: string;
4219042190
readonly event: string;
4219142191
readonly head_branch: string;
42192-
readonly head_commit?: Record<string, never>;
42192+
readonly head_commit?: Record<string, never> | null;
4219342193
readonly head_repository?: {
4219442194
readonly archive_url?: string;
4219542195
readonly assignees_url?: string;
@@ -42496,7 +42496,7 @@ export type components = {
4249642496
readonly created_at: string;
4249742497
readonly event: string;
4249842498
readonly head_branch: string;
42499-
readonly head_commit?: Record<string, never>;
42499+
readonly head_commit?: Record<string, never> | null;
4250042500
readonly head_repository?: {
4250142501
readonly archive_url?: string;
4250242502
readonly assignees_url?: string;
@@ -42844,7 +42844,7 @@ export type components = {
4284442844
readonly created_at: string;
4284542845
readonly event: string;
4284642846
readonly head_branch: string;
42847-
readonly head_commit?: Record<string, never>;
42847+
readonly head_commit?: Record<string, never> | null;
4284842848
readonly head_repository?: {
4284942849
readonly archive_url?: string;
4285042850
readonly assignees_url?: string;
@@ -44324,7 +44324,7 @@ export type components = {
4432444324
readonly labels_url?: string;
4432544325
readonly language?: unknown;
4432644326
readonly languages_url?: string;
44327-
readonly license?: Record<string, never>;
44327+
readonly license?: Record<string, never> | null;
4432844328
readonly merges_url?: string;
4432944329
readonly milestones_url?: string;
4433044330
readonly mirror_url?: unknown;
@@ -45131,7 +45131,7 @@ export type components = {
4513145131
readonly url?: string;
4513245132
readonly user_view_type?: string;
4513345133
} | null;
45134-
readonly assignees?: readonly Record<string, never>[];
45134+
readonly assignees?: readonly (Record<string, never> | null)[];
4513545135
readonly author_association?: string;
4513645136
readonly body?: string | null;
4513745137
readonly closed_at?: string | null;
@@ -45158,10 +45158,10 @@ export type components = {
4515845158
}[];
4515945159
readonly labels_url?: string;
4516045160
readonly locked: boolean;
45161-
readonly milestone?: Record<string, never>;
45161+
readonly milestone?: Record<string, never> | null;
4516245162
readonly node_id?: string;
4516345163
readonly number?: number;
45164-
readonly performed_via_github_app?: Record<string, never>;
45164+
readonly performed_via_github_app?: Record<string, never> | null;
4516545165
readonly reactions?: {
4516645166
readonly "+1"?: number;
4516745167
readonly "-1"?: number;
@@ -45675,7 +45675,7 @@ export type components = {
4567545675
readonly url?: string;
4567645676
readonly user_view_type?: string;
4567745677
} | null;
45678-
readonly assignees?: readonly Record<string, never>[];
45678+
readonly assignees?: readonly (Record<string, never> | null)[];
4567945679
readonly author_association?: string;
4568045680
readonly body?: string | null;
4568145681
readonly closed_at?: string | null;
@@ -45702,10 +45702,10 @@ export type components = {
4570245702
}[];
4570345703
readonly labels_url?: string;
4570445704
readonly locked: boolean;
45705-
readonly milestone?: Record<string, never>;
45705+
readonly milestone?: Record<string, never> | null;
4570645706
readonly node_id?: string;
4570745707
readonly number?: number;
45708-
readonly performed_via_github_app?: Record<string, never>;
45708+
readonly performed_via_github_app?: Record<string, never> | null;
4570945709
readonly reactions?: {
4571045710
readonly "+1"?: number;
4571145711
readonly "-1"?: number;
@@ -46221,7 +46221,7 @@ export type components = {
4622146221
readonly url?: string;
4622246222
readonly user_view_type?: string;
4622346223
} | null;
46224-
readonly assignees?: readonly Record<string, never>[];
46224+
readonly assignees?: readonly (Record<string, never> | null)[];
4622546225
readonly author_association?: string;
4622646226
readonly body?: string | null;
4622746227
readonly closed_at?: string | null;
@@ -46248,10 +46248,10 @@ export type components = {
4624846248
}[];
4624946249
readonly labels_url?: string;
4625046250
readonly locked: boolean;
46251-
readonly milestone?: Record<string, never>;
46251+
readonly milestone?: Record<string, never> | null;
4625246252
readonly node_id?: string;
4625346253
readonly number?: number;
46254-
readonly performed_via_github_app?: Record<string, never>;
46254+
readonly performed_via_github_app?: Record<string, never> | null;
4625546255
readonly reactions?: {
4625646256
readonly "+1"?: number;
4625746257
readonly "-1"?: number;
@@ -46744,8 +46744,8 @@ export type components = {
4674446744
} | null;
4674546745
} & {
4674646746
readonly active_lock_reason?: string | null;
46747-
readonly assignee?: Record<string, never>;
46748-
readonly assignees?: readonly Record<string, never>[];
46747+
readonly assignee?: Record<string, never> | null;
46748+
readonly assignees?: readonly (Record<string, never> | null)[];
4674946749
readonly author_association?: string;
4675046750
readonly body?: string | null;
4675146751
readonly closed_at: string | null;
@@ -46755,13 +46755,13 @@ export type components = {
4675546755
readonly events_url?: string;
4675646756
readonly html_url?: string;
4675746757
readonly id?: number;
46758-
readonly labels?: readonly Record<string, never>[];
46758+
readonly labels?: readonly (Record<string, never> | null)[];
4675946759
readonly labels_url?: string;
4676046760
readonly locked?: boolean;
46761-
readonly milestone?: Record<string, never>;
46761+
readonly milestone?: Record<string, never> | null;
4676246762
readonly node_id?: string;
4676346763
readonly number?: number;
46764-
readonly performed_via_github_app?: Record<string, never>;
46764+
readonly performed_via_github_app?: Record<string, never> | null;
4676546765
readonly reactions?: {
4676646766
readonly "+1"?: number;
4676746767
readonly "-1"?: number;
@@ -52843,8 +52843,8 @@ export type components = {
5284352843
readonly body?: string | Record<string, never>;
5284452844
readonly body_html?: string;
5284552845
readonly container_metadata?: {
52846-
readonly labels?: Record<string, never>;
52847-
readonly manifest?: Record<string, never>;
52846+
readonly labels?: Record<string, never> | null;
52847+
readonly manifest?: Record<string, never> | null;
5284852848
readonly tag?: {
5284952849
readonly digest?: string;
5285052850
readonly name?: string;
@@ -52869,19 +52869,19 @@ export type components = {
5286952869
readonly name?: string;
5287052870
readonly version?: string;
5287152871
readonly npm_user?: string;
52872-
readonly author?: Record<string, never>;
52873-
readonly bugs?: Record<string, never>;
52872+
readonly author?: Record<string, never> | null;
52873+
readonly bugs?: Record<string, never> | null;
5287452874
readonly dependencies?: Record<string, never>;
5287552875
readonly dev_dependencies?: Record<string, never>;
5287652876
readonly peer_dependencies?: Record<string, never>;
5287752877
readonly optional_dependencies?: Record<string, never>;
5287852878
readonly description?: string;
52879-
readonly dist?: Record<string, never>;
52879+
readonly dist?: Record<string, never> | null;
5288052880
readonly git_head?: string;
5288152881
readonly homepage?: string;
5288252882
readonly license?: string;
5288352883
readonly main?: string;
52884-
readonly repository?: Record<string, never>;
52884+
readonly repository?: Record<string, never> | null;
5288552885
readonly scripts?: Record<string, never>;
5288652886
readonly id?: string;
5288752887
readonly node_version?: string;
@@ -52894,7 +52894,7 @@ export type components = {
5289452894
readonly files?: readonly string[];
5289552895
readonly bin?: Record<string, never>;
5289652896
readonly man?: Record<string, never>;
52897-
readonly directories?: Record<string, never>;
52897+
readonly directories?: Record<string, never> | null;
5289852898
readonly os?: readonly string[];
5289952899
readonly cpu?: readonly string[];
5290052900
readonly readme?: string;
@@ -82202,8 +82202,8 @@ export type components = {
8220282202
readonly body?: string | Record<string, never>;
8220382203
readonly body_html?: string;
8220482204
readonly container_metadata?: {
82205-
readonly labels?: Record<string, never>;
82206-
readonly manifest?: Record<string, never>;
82205+
readonly labels?: Record<string, never> | null;
82206+
readonly manifest?: Record<string, never> | null;
8220782207
readonly tag?: {
8220882208
readonly digest?: string;
8220982209
readonly name?: string;
@@ -82470,7 +82470,7 @@ export type components = {
8247082470
readonly updated_at: string;
8247182471
readonly version: string;
8247282472
};
82473-
readonly registry: Record<string, never>;
82473+
readonly registry: Record<string, never> | null;
8247482474
readonly updated_at: string;
8247582475
};
8247682476
readonly repository?: components["schemas"]["repository-webhooks"];
@@ -85136,7 +85136,7 @@ export type components = {
8513685136
readonly head_branch?: string | null;
8513785137
/** @description The name of the workflow. */
8513885138
readonly workflow_name?: string | null;
85139-
readonly steps?: readonly Record<string, never>[];
85139+
readonly steps?: readonly (Record<string, never> | null)[];
8514085140
readonly url?: string;
8514185141
};
8514285142
readonly deployment?: components["schemas"]["deployment"];

0 commit comments

Comments
 (0)