Skip to content

Commit

Permalink
[typescript-axios] Add User-Agent Header to Default Axios (#20067)
Browse files Browse the repository at this point in the history
* [typescript-axios] Add User-Agent Header to Default Axios

* fix if `npmVersion` doesn't exist

* generate samples

* single line solution

* move user agent header to config

* generate samples

* splat for headers as well

* samples

* move headers above baseOptions

* samples

* commas are hard

* samples again
  • Loading branch information
ckoegel authored Dec 17, 2024
1 parent 9fec13a commit 289425b
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator{{#npmVersion}}/{{npmVersion}}{{/npmVersion}}/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/1.0.0/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/1.0.0/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/1.0.0/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/1.0.0/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/1.0.0/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export class Configuration {
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.baseOptions = {
headers: {
...param.baseOptions?.headers,
'User-Agent': "OpenAPI-Generator/typescript-axios"
},
...param.baseOptions
};
this.formDataCtor = param.formDataCtor;
}

Expand Down

0 comments on commit 289425b

Please sign in to comment.