Skip to content

Commit 2c38d0d

Browse files
authored
[typescript-fetch][Fix] oneOf models are generated without ...ToJSONTyped functions but models referencing still try to import (#20046)
* Fix #19858 * re-generate the samples
1 parent 28e02fc commit 2c38d0d

File tree

163 files changed

+654
-646
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+654
-646
lines changed

modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
108108
{{/hasVars}}
109109
}
110110

111-
export function {{classname}}ToJSON(json: any): {{classname}} {
112-
return {{classname}}ToJSONTyped(json, false);
113-
}
111+
export function {{classname}}ToJSON(json: any): {{classname}} {
112+
return {{classname}}ToJSONTyped(json, false);
113+
}
114114

115-
export function {{classname}}ToJSONTyped(value?: {{#hasReadOnly}}Omit<{{classname}}, {{#readOnlyVars}}'{{baseName}}'{{^-last}}|{{/-last}}{{/readOnlyVars}}>{{/hasReadOnly}}{{^hasReadOnly}}{{classname}}{{/hasReadOnly}} | null, ignoreDiscriminator: boolean = false): any {
115+
export function {{classname}}ToJSONTyped(value?: {{#hasReadOnly}}Omit<{{classname}}, {{#readOnlyVars}}'{{baseName}}'{{^-last}}|{{/-last}}{{/readOnlyVars}}>{{/hasReadOnly}}{{^hasReadOnly}}{{classname}}{{/hasReadOnly}} | null, ignoreDiscriminator: boolean = false): any {
116116
{{#hasVars}}
117117
if (value == null) {
118118
return value;

modules/openapi-generator/src/main/resources/typescript-fetch/modelOneOf.mustache

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
4141
{{/discriminator}}
4242
}
4343

44-
export function {{classname}}ToJSON(value?: {{classname}} | null): any {
44+
export function {{classname}}ToJSON(json: any): any {
45+
return {{classname}}ToJSONTyped(json, false);
46+
}
47+
48+
export function {{classname}}ToJSONTyped(value?: {{classname}} | null, ignoreDiscriminator: boolean = false): any {
4549
if (value == null) {
4650
return value;
4751
}

samples/client/others/typescript-fetch/self-import-issue/models/AbstractUserDto.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ export function AbstractUserDtoFromJSONTyped(json: any, ignoreDiscriminator: boo
8080
};
8181
}
8282

83-
export function AbstractUserDtoToJSON(json: any): AbstractUserDto {
84-
return AbstractUserDtoToJSONTyped(json, false);
85-
}
83+
export function AbstractUserDtoToJSON(json: any): AbstractUserDto {
84+
return AbstractUserDtoToJSONTyped(json, false);
85+
}
8686

87-
export function AbstractUserDtoToJSONTyped(value?: AbstractUserDto | null, ignoreDiscriminator: boolean = false): any {
87+
export function AbstractUserDtoToJSONTyped(value?: AbstractUserDto | null, ignoreDiscriminator: boolean = false): any {
8888
if (value == null) {
8989
return value;
9090
}

samples/client/others/typescript-fetch/self-import-issue/models/BranchDto.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ export function BranchDtoFromJSONTyped(json: any, ignoreDiscriminator: boolean):
4848
};
4949
}
5050

51-
export function BranchDtoToJSON(json: any): BranchDto {
52-
return BranchDtoToJSONTyped(json, false);
53-
}
51+
export function BranchDtoToJSON(json: any): BranchDto {
52+
return BranchDtoToJSONTyped(json, false);
53+
}
5454

55-
export function BranchDtoToJSONTyped(value?: BranchDto | null, ignoreDiscriminator: boolean = false): any {
55+
export function BranchDtoToJSONTyped(value?: BranchDto | null, ignoreDiscriminator: boolean = false): any {
5656
if (value == null) {
5757
return value;
5858
}

samples/client/others/typescript-fetch/self-import-issue/models/InternalAuthenticatedUserDto.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ export function InternalAuthenticatedUserDtoFromJSONTyped(json: any, ignoreDiscr
5151
return json;
5252
}
5353

54-
export function InternalAuthenticatedUserDtoToJSON(json: any): InternalAuthenticatedUserDto {
55-
return InternalAuthenticatedUserDtoToJSONTyped(json, false);
56-
}
54+
export function InternalAuthenticatedUserDtoToJSON(json: any): InternalAuthenticatedUserDto {
55+
return InternalAuthenticatedUserDtoToJSONTyped(json, false);
56+
}
5757

58-
export function InternalAuthenticatedUserDtoToJSONTyped(value?: InternalAuthenticatedUserDto | null, ignoreDiscriminator: boolean = false): any {
58+
export function InternalAuthenticatedUserDtoToJSONTyped(value?: InternalAuthenticatedUserDto | null, ignoreDiscriminator: boolean = false): any {
5959
return value;
6060
}
6161

samples/client/others/typescript-fetch/self-import-issue/models/RemoteAuthenticatedUserDto.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ export function RemoteAuthenticatedUserDtoFromJSONTyped(json: any, ignoreDiscrim
5151
return json;
5252
}
5353

54-
export function RemoteAuthenticatedUserDtoToJSON(json: any): RemoteAuthenticatedUserDto {
55-
return RemoteAuthenticatedUserDtoToJSONTyped(json, false);
56-
}
54+
export function RemoteAuthenticatedUserDtoToJSON(json: any): RemoteAuthenticatedUserDto {
55+
return RemoteAuthenticatedUserDtoToJSONTyped(json, false);
56+
}
5757

58-
export function RemoteAuthenticatedUserDtoToJSONTyped(value?: RemoteAuthenticatedUserDto | null, ignoreDiscriminator: boolean = false): any {
58+
export function RemoteAuthenticatedUserDtoToJSONTyped(value?: RemoteAuthenticatedUserDto | null, ignoreDiscriminator: boolean = false): any {
5959
return value;
6060
}
6161

samples/client/petstore/typescript-fetch/builds/allOf-nullable/models/Club.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ export function ClubFromJSONTyped(json: any, ignoreDiscriminator: boolean): Club
5656
};
5757
}
5858

59-
export function ClubToJSON(json: any): Club {
60-
return ClubToJSONTyped(json, false);
61-
}
59+
export function ClubToJSON(json: any): Club {
60+
return ClubToJSONTyped(json, false);
61+
}
6262

63-
export function ClubToJSONTyped(value?: Club | null, ignoreDiscriminator: boolean = false): any {
63+
export function ClubToJSONTyped(value?: Club | null, ignoreDiscriminator: boolean = false): any {
6464
if (value == null) {
6565
return value;
6666
}

samples/client/petstore/typescript-fetch/builds/allOf-nullable/models/Owner.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ export function OwnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): Own
4848
};
4949
}
5050

51-
export function OwnerToJSON(json: any): Owner {
52-
return OwnerToJSONTyped(json, false);
53-
}
51+
export function OwnerToJSON(json: any): Owner {
52+
return OwnerToJSONTyped(json, false);
53+
}
5454

55-
export function OwnerToJSONTyped(value?: Owner | null, ignoreDiscriminator: boolean = false): any {
55+
export function OwnerToJSONTyped(value?: Owner | null, ignoreDiscriminator: boolean = false): any {
5656
if (value == null) {
5757
return value;
5858
}

samples/client/petstore/typescript-fetch/builds/allOf-readonly/models/Club.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ export function ClubFromJSONTyped(json: any, ignoreDiscriminator: boolean): Club
5656
};
5757
}
5858

59-
export function ClubToJSON(json: any): Club {
60-
return ClubToJSONTyped(json, false);
61-
}
59+
export function ClubToJSON(json: any): Club {
60+
return ClubToJSONTyped(json, false);
61+
}
6262

63-
export function ClubToJSONTyped(value?: Omit<Club, 'owner'> | null, ignoreDiscriminator: boolean = false): any {
63+
export function ClubToJSONTyped(value?: Omit<Club, 'owner'> | null, ignoreDiscriminator: boolean = false): any {
6464
if (value == null) {
6565
return value;
6666
}

samples/client/petstore/typescript-fetch/builds/allOf-readonly/models/Owner.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ export function OwnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): Own
4848
};
4949
}
5050

51-
export function OwnerToJSON(json: any): Owner {
52-
return OwnerToJSONTyped(json, false);
53-
}
51+
export function OwnerToJSON(json: any): Owner {
52+
return OwnerToJSONTyped(json, false);
53+
}
5454

55-
export function OwnerToJSONTyped(value?: Owner | null, ignoreDiscriminator: boolean = false): any {
55+
export function OwnerToJSONTyped(value?: Owner | null, ignoreDiscriminator: boolean = false): any {
5656
if (value == null) {
5757
return value;
5858
}

0 commit comments

Comments
 (0)