File tree Expand file tree Collapse file tree 3 files changed +23
-22
lines changed Expand file tree Collapse file tree 3 files changed +23
-22
lines changed Original file line number Diff line number Diff line change @@ -92,18 +92,21 @@ export default function generateTypesV3(
92
92
93
93
let properties = createKeys ( node . properties || { } , node . required ) ;
94
94
95
- // if additional properties, add to end of properties
96
- if ( node . additionalProperties ) {
97
- properties += `[key: string]: ${
98
- node . additionalProperties === true
99
- ? "any"
100
- : transform ( node . additionalProperties ) || "any"
101
- } ;\n`;
102
- }
95
+ // if additional properties, add an intersection with a generic map type
96
+ const additionalProperties = node . additionalProperties
97
+ ? [
98
+ `{ [key: string]: ${
99
+ node . additionalProperties === true
100
+ ? "any"
101
+ : transform ( node . additionalProperties ) || "any"
102
+ } ;}\n`,
103
+ ]
104
+ : [ ] ;
103
105
104
106
return tsIntersectionOf ( [
105
107
...( node . allOf ? ( node . allOf as any [ ] ) . map ( transform ) : [ ] ) , // append allOf first
106
- ...( properties ? [ `{ ${ properties } }` ] : [ ] ) , // then properties + additionalProperties
108
+ ...( properties ? [ `{ ${ properties } }` ] : [ ] ) , // then properties
109
+ ...additionalProperties , // then additional properties
107
110
] ) ;
108
111
}
109
112
case "array" : {
Original file line number Diff line number Diff line change @@ -86,13 +86,13 @@ export interface paths {
86
86
* response
87
87
*/
88
88
"201": {
89
- "application/json": components["schemas"]["integration"] & {
90
- client_id: string;
91
- client_secret : string;
92
- webhook_secret : string;
93
- pem : string;
94
- [key: string]: any ;
95
- } ;
89
+ "application/json": components["schemas"]["integration"] &
90
+ ({
91
+ client_id : string;
92
+ client_secret : string;
93
+ webhook_secret : string;
94
+ pem: string ;
95
+ } & { [key: string]: any }) ;
96
96
};
97
97
"404": unknown;
98
98
"422": unknown;
@@ -20980,8 +20980,7 @@ export interface components {
20980
20980
metadata?: string;
20981
20981
contents?: string;
20982
20982
deployments?: string;
20983
- [key: string]: string;
20984
- };
20983
+ } & { [key: string]: string };
20985
20984
/**
20986
20985
* The list of events for the GitHub app
20987
20986
*/
@@ -20994,8 +20993,7 @@ export interface components {
20994
20993
client_secret?: string;
20995
20994
webhook_secret?: string;
20996
20995
pem?: string;
20997
- [key: string]: any;
20998
- };
20996
+ } & { [key: string]: any };
20999
20997
/**
21000
20998
* Basic Error
21001
20999
*/
Original file line number Diff line number Diff line change @@ -291,8 +291,8 @@ describe("OpenAPI3 features", () => {
291
291
format ( `
292
292
export interface components {
293
293
schemas: {
294
- additional_properties: { number?: number; [key: string]: any };
295
- additional_properties_string: { string?: string; [key: string]: string };
294
+ additional_properties: { number?: number; } & { [key: string]: any };
295
+ additional_properties_string: { string?: string } & { [key: string]: string };
296
296
}
297
297
}` )
298
298
) ;
You can’t perform that action at this time.
0 commit comments