Skip to content

Commit aef80c3

Browse files
committed
fix(typescript): handle nested inline objects with write/read only fields
1 parent 0ea8130 commit aef80c3

File tree

23 files changed

+230
-48
lines changed

23 files changed

+230
-48
lines changed

.changeset/warm-lemons-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix(typescript): handle nested inline objects with write/read only fields

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/read-write-only-custom-name/types.gen.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ export type WritableQuux = {
2929
baz?: Array<Baz>;
3030
};
3131

32+
export type ReadableCorge = {
33+
foo?: string;
34+
bar?: {
35+
readonly baz?: boolean;
36+
};
37+
};
38+
39+
export type WritableCorge = {
40+
foo?: string;
41+
};
42+
3243
export type PostFooReadData = {
3344
body: WritableFooRead;
3445
path?: never;

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/read-write-only-ignore/types.gen.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ export type Quux = {
2121
qux?: QuxAllRead;
2222
};
2323

24+
export type Corge = {
25+
foo?: string;
26+
bar?: {
27+
readonly baz?: boolean;
28+
};
29+
};
30+
2431
export type PostFooReadData = {
2532
body: FooRead;
2633
path?: never;

packages/openapi-ts-tests/test/__snapshots__/2.0.x/read-write-only/types.gen.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ export type QuuxWritable = {
2929
baz?: Array<Baz>;
3030
};
3131

32+
export type CorgeReadable = {
33+
foo?: string;
34+
bar?: {
35+
readonly baz?: boolean;
36+
};
37+
};
38+
39+
export type CorgeWritable = {
40+
foo?: string;
41+
};
42+
3243
export type PostFooReadData = {
3344
body: FooReadWritable;
3445
path?: never;

packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/read-write-only-custom-name/types.gen.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ export type WritableQuux = {
4747
baz?: Array<Baz>;
4848
};
4949

50+
export type ReadableCorge = {
51+
bar?: {
52+
readonly baz?: boolean;
53+
};
54+
};
55+
56+
export type WritableCorge = {
57+
foo?: {
58+
baz?: boolean;
59+
};
60+
};
61+
5062
export type PostFooReadWriteData = {
5163
body: WritableFooReadWrite;
5264
path?: never;

packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/read-write-only-ignore/types.gen.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ export type Quux = {
3333
qux?: QuxAllRead;
3434
};
3535

36+
export type Corge = {
37+
foo?: {
38+
baz?: boolean;
39+
};
40+
bar?: {
41+
readonly baz?: boolean;
42+
};
43+
};
44+
3645
export type PostFooReadWriteData = {
3746
body: FooReadWrite;
3847
path?: never;

packages/openapi-ts-tests/test/__snapshots__/3.0.x/read-write-only/types.gen.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ export type QuuxWritable = {
4747
baz?: Array<Baz>;
4848
};
4949

50+
export type CorgeReadable = {
51+
bar?: {
52+
readonly baz?: boolean;
53+
};
54+
};
55+
56+
export type CorgeWritable = {
57+
foo?: {
58+
baz?: boolean;
59+
};
60+
};
61+
5062
export type PostFooReadWriteData = {
5163
body: FooReadWriteWritable;
5264
path?: never;

packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/read-write-only-custom-name/types.gen.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ export type WritableQuux = {
5151
baz?: Array<Baz>;
5252
};
5353

54+
export type ReadableCorge = {
55+
bar?: {
56+
readonly baz?: boolean;
57+
};
58+
};
59+
60+
export type WritableCorge = {
61+
foo?: {
62+
baz?: boolean;
63+
};
64+
};
65+
5466
export type PostFooReadWriteData = {
5567
body: WritableFooReadWrite;
5668
path?: never;

packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/read-write-only-ignore/types.gen.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ export type Quux = {
3737
qux?: QuxAllRead;
3838
};
3939

40+
export type Corge = {
41+
foo?: {
42+
baz?: boolean;
43+
};
44+
bar?: {
45+
readonly baz?: boolean;
46+
};
47+
};
48+
4049
export type PostFooReadWriteData = {
4150
body: FooReadWrite;
4251
path?: never;

packages/openapi-ts-tests/test/__snapshots__/3.1.x/read-write-only/types.gen.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ export type QuuxWritable = {
5151
baz?: Array<Baz>;
5252
};
5353

54+
export type CorgeReadable = {
55+
bar?: {
56+
readonly baz?: boolean;
57+
};
58+
};
59+
60+
export type CorgeWritable = {
61+
foo?: {
62+
baz?: boolean;
63+
};
64+
};
65+
5466
export type PostFooReadWriteData = {
5567
body: FooReadWriteWritable;
5668
path?: never;

0 commit comments

Comments
 (0)