Skip to content

Commit 763c77e

Browse files
fix: Produce typescript-axios and typescript-fetch code that compiles
with the "exactOptionalPropertyTypes" option.
1 parent 211f517 commit 763c77e

220 files changed

Lines changed: 1531 additions & 1504 deletions

File tree

Some content is hidden

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

modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export interface {{classname}}{{operationIdCamelCase}}Request {
363363
* {{description}}
364364
*/
365365
{{/description}}
366-
readonly {{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}
366+
readonly {{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^required}} | undefined{{/required}}
367367
{{^-last}}
368368

369369
{{/-last}}

modules/openapi-generator/src/main/resources/typescript-axios/configuration.mustache

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,56 @@
44

55

66
export interface ConfigurationParameters {
7-
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
8-
username?: string;
9-
password?: string;
10-
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
11-
basePath?: string;
12-
serverIndex?: number;
13-
baseOptions?: any;
14-
formDataCtor?: new () => any;
7+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>) | undefined;
8+
username?: string | undefined;
9+
password?: string | undefined;
10+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>) | undefined;
11+
basePath?: string | undefined;
12+
serverIndex?: number | undefined;
13+
baseOptions?: any | undefined;
14+
formDataCtor?: (new () => any) | undefined;
1515
}
1616

1717
export class Configuration {
1818
/**
1919
* parameter for apiKey security
2020
* @param name security name
2121
*/
22-
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
22+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>) | undefined;
2323
/**
2424
* parameter for basic security
2525
*/
26-
username?: string;
26+
username?: string | undefined;
2727
/**
2828
* parameter for basic security
2929
*/
30-
password?: string;
30+
password?: string | undefined;
3131
/**
3232
* parameter for oauth2 security
3333
* @param name security name
3434
* @param scopes oauth2 scope
3535
*/
36-
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
36+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>) | undefined;
3737
/**
3838
* override base path
3939
*/
40-
basePath?: string;
40+
basePath?: string | undefined;
4141
/**
4242
* override server index
4343
*/
44-
serverIndex?: number;
44+
serverIndex?: number | undefined;
4545
/**
4646
* base options for axios calls
4747
*/
48-
baseOptions?: any;
48+
baseOptions?: any | undefined;
4949
/**
5050
* The FormData constructor that will be used to create multipart form data
5151
* requests. You can inject this here so that execution environments that
5252
* do not support the FormData class can still run the generated client.
5353
*
5454
* @type {new () => FormData}
5555
*/
56-
formDataCtor?: new () => any;
56+
formDataCtor?: (new () => any) | undefined;
5757

5858
constructor(param: ConfigurationParameters = {}) {
5959
this.apiKey = param.apiKey;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
2424
*/
2525
{{/deprecated}}
2626
{{/description}}
27-
'{{baseName}}'{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}} | null{{/isNullable}};
27+
'{{baseName}}'{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}} | null{{/isNullable}}{{^required}} | undefined{{/required}};
2828
{{/vars}}
2929
}{{#hasEnums}}
3030

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
{{#allParams.0}}
2626
export interface {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request {
2727
{{#allParams}}
28-
{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{#hasReadOnly}}Omit<{{{dataType}}}, {{#readOnlyVars}}'{{baseName}}'{{^-last}}|{{/-last}}{{/readOnlyVars}}>{{/hasReadOnly}}{{^hasReadOnly}}{{{dataType}}}{{/hasReadOnly}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};
28+
{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{#hasReadOnly}}Omit<{{{dataType}}}, {{#readOnlyVars}}'{{baseName}}'{{^-last}}|{{/-last}}{{/readOnlyVars}}>{{/hasReadOnly}}{{^hasReadOnly}}{{{dataType}}}{{/hasReadOnly}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^required}} | undefined{{/required}};
2929
{{/allParams}}
3030
}
3131

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
1616
* @deprecated
1717
{{/deprecated}}
1818
*/
19-
{{#isReadOnly}}readonly {{/isReadOnly}}{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};
19+
{{#isReadOnly}}readonly {{/isReadOnly}}{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^required}} | undefined{{/required}};
2020
{{/vars}}
2121
}{{#hasEnums}}
2222

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export interface Payload{{#lambda.titlecase}}{{#lambda.camelcase}}{{nickname}}{{
6767
{{#allParams.0}}
6868
export interface Payload{{#lambda.titlecase}}{{#lambda.camelcase}}{{nickname}}{{/lambda.camelcase}}{{/lambda.titlecase}}Request {
6969
{{#allParams}}
70-
{{paramName}}{{^required}}?{{/required}}: {{{dataTypeAlternate}}};
70+
{{paramName}}{{^required}}?{{/required}}: {{{dataTypeAlternate}}}{{^required}} | undefined{{/required}};
7171
{{/allParams}}
7272
}
7373
{{/allParams.0}}

samples/client/echo_api/typescript-axios/build/api.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,41 @@ import type { RequestArgs } from './base';
2424
import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base';
2525

2626
export interface Bird {
27-
'size'?: string;
28-
'color'?: string;
27+
'size'?: string | undefined;
28+
'color'?: string | undefined;
2929
}
3030
export interface Category {
31-
'id'?: number;
32-
'name'?: string;
31+
'id'?: number | undefined;
32+
'name'?: string | undefined;
3333
}
3434
export interface DataQuery extends Query {
3535
/**
3636
* test suffix
3737
*/
38-
'suffix'?: string;
38+
'suffix'?: string | undefined;
3939
/**
4040
* Some text containing white spaces
4141
*/
42-
'text'?: string;
42+
'text'?: string | undefined;
4343
/**
4444
* A date
4545
*/
46-
'date'?: string;
46+
'date'?: string | undefined;
4747
}
4848

4949

5050
/**
5151
* to test the default value of properties
5252
*/
5353
export interface DefaultValue {
54-
'array_string_enum_ref_default'?: Array<StringEnumRef>;
55-
'array_string_enum_default'?: Array<DefaultValueArrayStringEnumDefaultEnum>;
56-
'array_string_default'?: Array<string>;
57-
'array_integer_default'?: Array<number>;
58-
'array_string'?: Array<string>;
59-
'array_string_nullable'?: Array<string> | null;
60-
'array_string_extension_nullable'?: Array<string> | null;
61-
'string_nullable'?: string | null;
54+
'array_string_enum_ref_default'?: Array<StringEnumRef> | undefined;
55+
'array_string_enum_default'?: Array<DefaultValueArrayStringEnumDefaultEnum> | undefined;
56+
'array_string_default'?: Array<string> | undefined;
57+
'array_integer_default'?: Array<number> | undefined;
58+
'array_string'?: Array<string> | undefined;
59+
'array_string_nullable'?: Array<string> | null | undefined;
60+
'array_string_extension_nullable'?: Array<string> | null | undefined;
61+
'string_nullable'?: string | null | undefined;
6262
}
6363

6464
export const DefaultValueArrayStringEnumDefaultEnum = {
@@ -70,20 +70,20 @@ export const DefaultValueArrayStringEnumDefaultEnum = {
7070
export type DefaultValueArrayStringEnumDefaultEnum = typeof DefaultValueArrayStringEnumDefaultEnum[keyof typeof DefaultValueArrayStringEnumDefaultEnum];
7171

7272
export interface NumberPropertiesOnly {
73-
'number'?: number;
74-
'float'?: number;
75-
'double'?: number;
73+
'number'?: number | undefined;
74+
'float'?: number | undefined;
75+
'double'?: number | undefined;
7676
}
7777
export interface Pet {
78-
'id'?: number;
78+
'id'?: number | undefined;
7979
'name': string;
80-
'category'?: Category;
80+
'category'?: Category | undefined;
8181
'photoUrls': Array<string>;
82-
'tags'?: Array<Tag>;
82+
'tags'?: Array<Tag> | undefined;
8383
/**
8484
* pet status in the store
8585
*/
86-
'status'?: PetStatusEnum;
86+
'status'?: PetStatusEnum | undefined;
8787
}
8888

8989
export const PetStatusEnum = {
@@ -98,8 +98,8 @@ export interface Query {
9898
/**
9999
* Query
100100
*/
101-
'id'?: number;
102-
'outcomes'?: Array<QueryOutcomesEnum>;
101+
'id'?: number | undefined;
102+
'outcomes'?: Array<QueryOutcomesEnum> | undefined;
103103
}
104104

105105
export const QueryOutcomesEnum = {
@@ -121,20 +121,20 @@ export type StringEnumRef = typeof StringEnumRef[keyof typeof StringEnumRef];
121121

122122

123123
export interface Tag {
124-
'id'?: number;
125-
'name'?: string;
124+
'id'?: number | undefined;
125+
'name'?: string | undefined;
126126
}
127127
export interface TestFormObjectMultipartRequestMarker {
128-
'name'?: string;
128+
'name'?: string | undefined;
129129
}
130130
export interface TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter {
131-
'size'?: string;
132-
'color'?: string;
133-
'id'?: number;
134-
'name'?: string;
131+
'size'?: string | undefined;
132+
'color'?: string | undefined;
133+
'id'?: number | undefined;
134+
'name'?: string | undefined;
135135
}
136136
export interface TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
137-
'values'?: Array<string>;
137+
'values'?: Array<string> | undefined;
138138
}
139139

140140
/**

samples/client/echo_api/typescript-axios/build/configuration.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,56 +14,56 @@
1414

1515

1616
export interface ConfigurationParameters {
17-
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
18-
username?: string;
19-
password?: string;
20-
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
21-
basePath?: string;
22-
serverIndex?: number;
23-
baseOptions?: any;
24-
formDataCtor?: new () => any;
17+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>) | undefined;
18+
username?: string | undefined;
19+
password?: string | undefined;
20+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>) | undefined;
21+
basePath?: string | undefined;
22+
serverIndex?: number | undefined;
23+
baseOptions?: any | undefined;
24+
formDataCtor?: (new () => any) | undefined;
2525
}
2626

2727
export class Configuration {
2828
/**
2929
* parameter for apiKey security
3030
* @param name security name
3131
*/
32-
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
32+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>) | undefined;
3333
/**
3434
* parameter for basic security
3535
*/
36-
username?: string;
36+
username?: string | undefined;
3737
/**
3838
* parameter for basic security
3939
*/
40-
password?: string;
40+
password?: string | undefined;
4141
/**
4242
* parameter for oauth2 security
4343
* @param name security name
4444
* @param scopes oauth2 scope
4545
*/
46-
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
46+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>) | undefined;
4747
/**
4848
* override base path
4949
*/
50-
basePath?: string;
50+
basePath?: string | undefined;
5151
/**
5252
* override server index
5353
*/
54-
serverIndex?: number;
54+
serverIndex?: number | undefined;
5555
/**
5656
* base options for axios calls
5757
*/
58-
baseOptions?: any;
58+
baseOptions?: any | undefined;
5959
/**
6060
* The FormData constructor that will be used to create multipart form data
6161
* requests. You can inject this here so that execution environments that
6262
* do not support the FormData class can still run the generated client.
6363
*
6464
* @type {new () => FormData}
6565
*/
66-
formDataCtor?: new () => any;
66+
formDataCtor?: (new () => any) | undefined;
6767

6868
constructor(param: ConfigurationParameters = {}) {
6969
this.apiKey = param.apiKey;

samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/configuration.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,56 +14,56 @@
1414

1515

1616
export interface ConfigurationParameters {
17-
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
18-
username?: string;
19-
password?: string;
20-
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
21-
basePath?: string;
22-
serverIndex?: number;
23-
baseOptions?: any;
24-
formDataCtor?: new () => any;
17+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>) | undefined;
18+
username?: string | undefined;
19+
password?: string | undefined;
20+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>) | undefined;
21+
basePath?: string | undefined;
22+
serverIndex?: number | undefined;
23+
baseOptions?: any | undefined;
24+
formDataCtor?: (new () => any) | undefined;
2525
}
2626

2727
export class Configuration {
2828
/**
2929
* parameter for apiKey security
3030
* @param name security name
3131
*/
32-
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
32+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>) | undefined;
3333
/**
3434
* parameter for basic security
3535
*/
36-
username?: string;
36+
username?: string | undefined;
3737
/**
3838
* parameter for basic security
3939
*/
40-
password?: string;
40+
password?: string | undefined;
4141
/**
4242
* parameter for oauth2 security
4343
* @param name security name
4444
* @param scopes oauth2 scope
4545
*/
46-
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
46+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>) | undefined;
4747
/**
4848
* override base path
4949
*/
50-
basePath?: string;
50+
basePath?: string | undefined;
5151
/**
5252
* override server index
5353
*/
54-
serverIndex?: number;
54+
serverIndex?: number | undefined;
5555
/**
5656
* base options for axios calls
5757
*/
58-
baseOptions?: any;
58+
baseOptions?: any | undefined;
5959
/**
6060
* The FormData constructor that will be used to create multipart form data
6161
* requests. You can inject this here so that execution environments that
6262
* do not support the FormData class can still run the generated client.
6363
*
6464
* @type {new () => FormData}
6565
*/
66-
formDataCtor?: new () => any;
66+
formDataCtor?: (new () => any) | undefined;
6767

6868
constructor(param: ConfigurationParameters = {}) {
6969
this.apiKey = param.apiKey;

0 commit comments

Comments
 (0)