Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ export class {{classname}} extends BaseService {

{{/isResponseFile}}
let localVarPath = `{{{path}}}`;
return this.httpClient.request{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}('{{httpMethod}}', `${this.configuration.basePath}${localVarPath}`,
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}('{{httpMethod}}', `${basePath}${localVarPath}`,
{
{{#httpContextInOptions}}
context: localVarHttpContext,
Expand All @@ -297,7 +298,7 @@ export class {{classname}} extends BaseService {
{{^isResponseFile}}
responseType: <any>responseType_,
{{/isResponseFile}}
withCredentials: this.configuration.withCredentials,
...(withCredentials ? { withCredentials } : {}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ?? Or || ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I misunderstand the suggestion to use the nullish coalescing operator, but if I use it I would have to specify a default value for withCredentials.

withCredentials is type of boolean and is optional, see here. With exactOptionalPropertyTypes an assignment of undefined wouldn't be allowed.

withCredentials: withCredentials ?? false seemed more like a breaking change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I would be fine to go this route. I had a rough look at the Angular code and it seems that no distinction is made between undefined and false.

headers: localVarHeaders,
observe: observe,
{{#httpTransferCacheInOptions}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,30 @@ export class {{configurationClassName}} {
*/
credentials: {[ key: string ]: string | (() => string | undefined)};

constructor(configurationParameters: {{configurationParametersInterfaceName}} = {}) {
this.apiKeys = configurationParameters.apiKeys;
this.username = configurationParameters.username;
this.password = configurationParameters.password;
this.accessToken = configurationParameters.accessToken;
this.basePath = configurationParameters.basePath;
this.withCredentials = configurationParameters.withCredentials;
this.encoder = configurationParameters.encoder;
if (configurationParameters.encodeParam) {
this.encodeParam = configurationParameters.encodeParam;
constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder, password, username, withCredentials }: {{configurationParametersInterfaceName}} = {}) {
if (apiKeys) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all guarded now, but beforehand they weren't, if the containing object was truthy all of them would have been set, no matter if truthy or not. Do we need to look into it in more detail on whether that behavior changes are fully backwards compatible?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is absolutely correct. I have adapted it by explicitly checking for undefined. The only exceptions are encoder and apiKeys, as both can only be of data type truthy or undefined.

this.apiKeys = apiKeys;
}
else {
this.encodeParam = param => this.defaultEncodeParam(param);
if (username !== undefined) {
this.username = username;
}
if (configurationParameters.credentials) {
this.credentials = configurationParameters.credentials;
if (password !== undefined) {
this.password = password;
}
else {
this.credentials = {};
if (accessToken !== undefined) {
this.accessToken = accessToken;
}
if (basePath !== undefined) {
this.basePath = basePath;
}
if (withCredentials !== undefined) {
this.withCredentials = withCredentials;
}
if (encoder) {
this.encoder = encoder;
}
this.encodeParam = encodeParam ?? (param => this.defaultEncodeParam(param));
this.credentials = credentials ?? {};
{{#authMethods}}

// init default {{name}} credential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"module": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}commonjs{{/supportsES6}}",
"moduleResolution": "node",
"removeComments": true,
"strictNullChecks": true,
"exactOptionalPropertyTypes": true,
"sourceMap": true,
"outDir": "./dist",
"noLib": false,
Expand Down
6 changes: 6 additions & 0 deletions samples/client/echo_api/java/native/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator).
# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option.
#
# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
# For example, uncomment below to build for Android
#target = android
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ export class PetService extends BaseService {
}

let localVarPath = `/pet/mapped`;
return this.httpClient.request<Array<PetWithMappedDiscriminatorModel>>('get', `${this.configuration.basePath}${localVarPath}`,
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Array<PetWithMappedDiscriminatorModel>>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
transferCache: localVarTransferCache,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,30 @@ export class Configuration {
*/
credentials: {[ key: string ]: string | (() => string | undefined)};

constructor(configurationParameters: ConfigurationParameters = {}) {
this.apiKeys = configurationParameters.apiKeys;
this.username = configurationParameters.username;
this.password = configurationParameters.password;
this.accessToken = configurationParameters.accessToken;
this.basePath = configurationParameters.basePath;
this.withCredentials = configurationParameters.withCredentials;
this.encoder = configurationParameters.encoder;
if (configurationParameters.encodeParam) {
this.encodeParam = configurationParameters.encodeParam;
constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder, password, username, withCredentials }: ConfigurationParameters = {}) {
if (apiKeys) {
this.apiKeys = apiKeys;
}
else {
this.encodeParam = param => this.defaultEncodeParam(param);
if (username !== undefined) {
this.username = username;
}
if (configurationParameters.credentials) {
this.credentials = configurationParameters.credentials;
if (password !== undefined) {
this.password = password;
}
else {
this.credentials = {};
if (accessToken !== undefined) {
this.accessToken = accessToken;
}
if (basePath !== undefined) {
this.basePath = basePath;
}
if (withCredentials !== undefined) {
this.withCredentials = withCredentials;
}
if (encoder) {
this.encoder = encoder;
}
this.encodeParam = encodeParam ?? (param => this.defaultEncodeParam(param));
this.credentials = credentials ?? {};
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ export class PetService extends BaseService {
}

let localVarPath = `/pet/mapped`;
return this.httpClient.request<Array<PetWithMappedDiscriminatorModel>>('get', `${this.configuration.basePath}${localVarPath}`,
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Array<PetWithMappedDiscriminatorModel>>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
transferCache: localVarTransferCache,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,30 @@ export class Configuration {
*/
credentials: {[ key: string ]: string | (() => string | undefined)};

constructor(configurationParameters: ConfigurationParameters = {}) {
this.apiKeys = configurationParameters.apiKeys;
this.username = configurationParameters.username;
this.password = configurationParameters.password;
this.accessToken = configurationParameters.accessToken;
this.basePath = configurationParameters.basePath;
this.withCredentials = configurationParameters.withCredentials;
this.encoder = configurationParameters.encoder;
if (configurationParameters.encodeParam) {
this.encodeParam = configurationParameters.encodeParam;
constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder, password, username, withCredentials }: ConfigurationParameters = {}) {
if (apiKeys) {
this.apiKeys = apiKeys;
}
else {
this.encodeParam = param => this.defaultEncodeParam(param);
if (username !== undefined) {
this.username = username;
}
if (configurationParameters.credentials) {
this.credentials = configurationParameters.credentials;
if (password !== undefined) {
this.password = password;
}
else {
this.credentials = {};
if (accessToken !== undefined) {
this.accessToken = accessToken;
}
if (basePath !== undefined) {
this.basePath = basePath;
}
if (withCredentials !== undefined) {
this.withCredentials = withCredentials;
}
if (encoder) {
this.encoder = encoder;
}
this.encodeParam = encodeParam ?? (param => this.defaultEncodeParam(param));
this.credentials = credentials ?? {};
}

/**
Expand Down
6 changes: 6 additions & 0 deletions samples/client/petstore/java/native-async/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator).
# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option.
#
# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
# For example, uncomment below to build for Android
#target = android
6 changes: 6 additions & 0 deletions samples/client/petstore/java/native-jakarta/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator).
# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option.
#
# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
# For example, uncomment below to build for Android
#target = android
6 changes: 6 additions & 0 deletions samples/client/petstore/java/native/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator).
# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option.
#
# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
# For example, uncomment below to build for Android
#target = android
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ export class DefaultService extends BaseService {
}

let localVarPath = `/`;
return this.httpClient.request<Fruit>('get', `${this.configuration.basePath}${localVarPath}`,
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Fruit>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
Expand Down Expand Up @@ -122,12 +123,13 @@ export class DefaultService extends BaseService {
}

let localVarPath = `/`;
return this.httpClient.request<any>('put', `${this.configuration.basePath}${localVarPath}`,
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<any>('put', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
body: body,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,30 @@ export class Configuration {
*/
credentials: {[ key: string ]: string | (() => string | undefined)};

constructor(configurationParameters: ConfigurationParameters = {}) {
this.apiKeys = configurationParameters.apiKeys;
this.username = configurationParameters.username;
this.password = configurationParameters.password;
this.accessToken = configurationParameters.accessToken;
this.basePath = configurationParameters.basePath;
this.withCredentials = configurationParameters.withCredentials;
this.encoder = configurationParameters.encoder;
if (configurationParameters.encodeParam) {
this.encodeParam = configurationParameters.encodeParam;
constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder, password, username, withCredentials }: ConfigurationParameters = {}) {
if (apiKeys) {
this.apiKeys = apiKeys;
}
else {
this.encodeParam = param => this.defaultEncodeParam(param);
if (username !== undefined) {
this.username = username;
}
if (configurationParameters.credentials) {
this.credentials = configurationParameters.credentials;
if (password !== undefined) {
this.password = password;
}
else {
this.credentials = {};
if (accessToken !== undefined) {
this.accessToken = accessToken;
}
if (basePath !== undefined) {
this.basePath = basePath;
}
if (withCredentials !== undefined) {
this.withCredentials = withCredentials;
}
if (encoder) {
this.encoder = encoder;
}
this.encodeParam = encodeParam ?? (param => this.defaultEncodeParam(param));
this.credentials = credentials ?? {};
}

/**
Expand Down
Loading