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
}

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AdditionalPropertiesClass.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export function AdditionalPropertiesClassFromJSONTyped(json: any, ignoreDiscrimi
5555
};
5656
}
5757

58-
export function AdditionalPropertiesClassToJSON(json: any): AdditionalPropertiesClass {
59-
return AdditionalPropertiesClassToJSONTyped(json, false);
60-
}
58+
export function AdditionalPropertiesClassToJSON(json: any): AdditionalPropertiesClass {
59+
return AdditionalPropertiesClassToJSONTyped(json, false);
60+
}
6161

62-
export function AdditionalPropertiesClassToJSONTyped(value?: AdditionalPropertiesClass | null, ignoreDiscriminator: boolean = false): any {
62+
export function AdditionalPropertiesClassToJSONTyped(value?: AdditionalPropertiesClass | null, ignoreDiscriminator: boolean = false): any {
6363
if (value == null) {
6464
return value;
6565
}

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ export function AllOfWithSingleRefFromJSONTyped(json: any, ignoreDiscriminator:
6565
};
6666
}
6767

68-
export function AllOfWithSingleRefToJSON(json: any): AllOfWithSingleRef {
69-
return AllOfWithSingleRefToJSONTyped(json, false);
70-
}
68+
export function AllOfWithSingleRefToJSON(json: any): AllOfWithSingleRef {
69+
return AllOfWithSingleRefToJSONTyped(json, false);
70+
}
7171

72-
export function AllOfWithSingleRefToJSONTyped(value?: AllOfWithSingleRef | null, ignoreDiscriminator: boolean = false): any {
72+
export function AllOfWithSingleRefToJSONTyped(value?: AllOfWithSingleRef | null, ignoreDiscriminator: boolean = false): any {
7373
if (value == null) {
7474
return value;
7575
}

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ export function AnimalFromJSONTyped(json: any, ignoreDiscriminator: boolean): An
6666
};
6767
}
6868

69-
export function AnimalToJSON(json: any): Animal {
70-
return AnimalToJSONTyped(json, false);
71-
}
69+
export function AnimalToJSON(json: any): Animal {
70+
return AnimalToJSONTyped(json, false);
71+
}
7272

73-
export function AnimalToJSONTyped(value?: Animal | null, ignoreDiscriminator: boolean = false): any {
73+
export function AnimalToJSONTyped(value?: Animal | null, ignoreDiscriminator: boolean = false): any {
7474
if (value == null) {
7575
return value;
7676
}

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayOfArrayOfNumberOnly.ts

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

51-
export function ArrayOfArrayOfNumberOnlyToJSON(json: any): ArrayOfArrayOfNumberOnly {
52-
return ArrayOfArrayOfNumberOnlyToJSONTyped(json, false);
53-
}
51+
export function ArrayOfArrayOfNumberOnlyToJSON(json: any): ArrayOfArrayOfNumberOnly {
52+
return ArrayOfArrayOfNumberOnlyToJSONTyped(json, false);
53+
}
5454

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

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayOfNumberOnly.ts

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

51-
export function ArrayOfNumberOnlyToJSON(json: any): ArrayOfNumberOnly {
52-
return ArrayOfNumberOnlyToJSONTyped(json, false);
53-
}
51+
export function ArrayOfNumberOnlyToJSON(json: any): ArrayOfNumberOnly {
52+
return ArrayOfNumberOnlyToJSONTyped(json, false);
53+
}
5454

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

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayTest.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ export function ArrayTestFromJSONTyped(json: any, ignoreDiscriminator: boolean):
7070
};
7171
}
7272

73-
export function ArrayTestToJSON(json: any): ArrayTest {
74-
return ArrayTestToJSONTyped(json, false);
75-
}
73+
export function ArrayTestToJSON(json: any): ArrayTest {
74+
return ArrayTestToJSONTyped(json, false);
75+
}
7676

77-
export function ArrayTestToJSONTyped(value?: ArrayTest | null, ignoreDiscriminator: boolean = false): any {
77+
export function ArrayTestToJSONTyped(value?: ArrayTest | null, ignoreDiscriminator: boolean = false): any {
7878
if (value == null) {
7979
return value;
8080
}

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Capitalization.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ export function CapitalizationFromJSONTyped(json: any, ignoreDiscriminator: bool
8484
};
8585
}
8686

87-
export function CapitalizationToJSON(json: any): Capitalization {
88-
return CapitalizationToJSONTyped(json, false);
89-
}
87+
export function CapitalizationToJSON(json: any): Capitalization {
88+
return CapitalizationToJSONTyped(json, false);
89+
}
9090

91-
export function CapitalizationToJSONTyped(value?: Capitalization | null, ignoreDiscriminator: boolean = false): any {
91+
export function CapitalizationToJSONTyped(value?: Capitalization | null, ignoreDiscriminator: boolean = false): any {
9292
if (value == null) {
9393
return value;
9494
}

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Cat.ts

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

59-
export function CatToJSON(json: any): Cat {
60-
return CatToJSONTyped(json, false);
61-
}
59+
export function CatToJSON(json: any): Cat {
60+
return CatToJSONTyped(json, false);
61+
}
6262

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

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Category.ts

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

59-
export function CategoryToJSON(json: any): Category {
60-
return CategoryToJSONTyped(json, false);
61-
}
59+
export function CategoryToJSON(json: any): Category {
60+
return CategoryToJSONTyped(json, false);
61+
}
6262

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

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ export function ChildWithNullableFromJSONTyped(json: any, ignoreDiscriminator: b
5858
};
5959
}
6060

61-
export function ChildWithNullableToJSON(json: any): ChildWithNullable {
62-
return ChildWithNullableToJSONTyped(json, false);
63-
}
61+
export function ChildWithNullableToJSON(json: any): ChildWithNullable {
62+
return ChildWithNullableToJSONTyped(json, false);
63+
}
6464

65-
export function ChildWithNullableToJSONTyped(value?: ChildWithNullable | null, ignoreDiscriminator: boolean = false): any {
65+
export function ChildWithNullableToJSONTyped(value?: ChildWithNullable | null, ignoreDiscriminator: boolean = false): any {
6666
if (value == null) {
6767
return value;
6868
}

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ClassModel.ts

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

51-
export function ClassModelToJSON(json: any): ClassModel {
52-
return ClassModelToJSONTyped(json, false);
53-
}
51+
export function ClassModelToJSON(json: any): ClassModel {
52+
return ClassModelToJSONTyped(json, false);
53+
}
5454

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

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Client.ts

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

51-
export function ClientToJSON(json: any): Client {
52-
return ClientToJSONTyped(json, false);
53-
}
51+
export function ClientToJSON(json: any): Client {
52+
return ClientToJSONTyped(json, false);
53+
}
5454

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

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/DeprecatedObject.ts

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

51-
export function DeprecatedObjectToJSON(json: any): DeprecatedObject {
52-
return DeprecatedObjectToJSONTyped(json, false);
53-
}
51+
export function DeprecatedObjectToJSON(json: any): DeprecatedObject {
52+
return DeprecatedObjectToJSONTyped(json, false);
53+
}
5454

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

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Dog.ts

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

59-
export function DogToJSON(json: any): Dog {
60-
return DogToJSONTyped(json, false);
61-
}
59+
export function DogToJSON(json: any): Dog {
60+
return DogToJSONTyped(json, false);
61+
}
6262

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

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumArrays.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ export function EnumArraysFromJSONTyped(json: any, ignoreDiscriminator: boolean)
7575
};
7676
}
7777

78-
export function EnumArraysToJSON(json: any): EnumArrays {
79-
return EnumArraysToJSONTyped(json, false);
80-
}
78+
export function EnumArraysToJSON(json: any): EnumArrays {
79+
return EnumArraysToJSONTyped(json, false);
80+
}
8181

82-
export function EnumArraysToJSONTyped(value?: EnumArrays | null, ignoreDiscriminator: boolean = false): any {
82+
export function EnumArraysToJSONTyped(value?: EnumArrays | null, ignoreDiscriminator: boolean = false): any {
8383
if (value == null) {
8484
return value;
8585
}

0 commit comments

Comments
 (0)