Skip to content

Commit 0869010

Browse files
committed
[typescript-axios] Conditionally set user-agent
The change in #20067 has caused some issues with clients which run in a Browser. This commit replaces that change, leaving the default User-Agent for axios unmodified, and only sets the User-Agent if the `http-user-agent` parameter is provided during generation time.
1 parent 187af2e commit 0869010

File tree

17 files changed

+21
-32
lines changed

17 files changed

+21
-32
lines changed

bin/configs/typescript-axios-echo-api.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ generatorName: typescript-axios
22
outputDir: samples/client/echo_api/typescript-axios/build
33
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
44
templateDir: modules/openapi-generator/src/main/resources/typescript-axios
5+
httpUserAgent: EchoApi/1.0.0
56
additionalProperties:
67
artifactId: echo-api-typescript-axios
78
hideGenerationTimestamp: "true"

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ export class Configuration {
7979
this.basePath = param.basePath;
8080
this.serverIndex = param.serverIndex;
8181
this.baseOptions = {
82+
...param.baseOptions,
8283
headers: {
84+
{{#httpUserAgent}}
85+
'User-Agent': "{{httpUserAgent}}",
86+
{{/httpUserAgent}}
8387
...param.baseOptions?.headers,
84-
'User-Agent': "OpenAPI-Generator{{#npmVersion}}/{{npmVersion}}{{/npmVersion}}/typescript-axios"
8588
},
86-
...param.baseOptions
8789
};
8890
this.formDataCtor = param.formDataCtor;
8991
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
95+
'User-Agent': "EchoApi/1.0.0",
9496
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/1.0.0/typescript-axios"
9697
},
97-
...param.baseOptions
9898
};
9999
this.formDataCtor = param.formDataCtor;
100100
}

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/composed-schemas/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/default/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/es6-target/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/1.0.0/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/test-petstore/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/with-complex-headers/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/1.0.0/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/with-interfaces-and-with-single-request-param/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/with-interfaces/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/with-node-imports/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/1.0.0/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/with-npm-version/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/1.0.0/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/with-single-request-parameters/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

samples/client/petstore/typescript-axios/builds/with-string-enums/configuration.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ export class Configuration {
9090
this.basePath = param.basePath;
9191
this.serverIndex = param.serverIndex;
9292
this.baseOptions = {
93+
...param.baseOptions,
9394
headers: {
9495
...param.baseOptions?.headers,
95-
'User-Agent': "OpenAPI-Generator/typescript-axios"
9696
},
97-
...param.baseOptions
9897
};
9998
this.formDataCtor = param.formDataCtor;
10099
}

0 commit comments

Comments
 (0)