You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using our site in Chrome there is an error in the console:
Refused to set unsafe header "User-Agent"
We use the openapi-generator-cli tool that generates the ApiClient.js setting the header User-Agent even though we haven't specified it in the cli. There is no way, that we've seen, to tell the cli to not set the User-Agent header and therefore no way to remove the above error from Chrome, besides manually removing it after the build.
We use: this command to generate our js client code
openapi-generator-cli generate -g javascript -i swagger.json -o api --additional-properties=usePromises=true
Steps to reproduce
Generate client js code by running the below command on an example swagger.json
openapi-generator-cli generate -g javascript -i swagger.json -o api --additional-properties=usePromises=true
Navigate to the generated code api/src/ApiClient.js you will see the User-Agent code is there:
/**
* The default HTTP headers to be included for all API calls.
* @type {Array.<String>}
* @default {}
*/
this.defaultHeaders = {
'User-Agent': 'OpenAPI-Generator/1.0.0/Javascript'
};
/**
Even though it wasn't specified.
Related issues/PRs
I believe this commit was where the issue was introduced.
Suggest a fix
The mustache template should probably check to see if the User Agent variable was passed before generating it.
The text was updated successfully, but these errors were encountered:
The defaultHeaders found within the _this3: ApiClient scope:
It's been a few months since this bug report was first written. No one has picked this up. Does this imply that the openapi generator is no longer supported?
Description
When using our site in Chrome there is an error in the console:
We use the openapi-generator-cli tool that generates the ApiClient.js setting the header
User-Agent
even though we haven't specified it in the cli. There is no way, that we've seen, to tell the cli to not set the User-Agent header and therefore no way to remove the above error from Chrome, besides manually removing it after the build.openapi-generator version
With version :
The actual version in yarn is:
"resolved" "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.4.26.tgz"
Generation Details
We use: this command to generate our js client code
Steps to reproduce
Generate client js code by running the below command on an example swagger.json
Navigate to the generated code
api/src/ApiClient.js
you will see the User-Agent code is there:Even though it wasn't specified.
Related issues/PRs
I believe
this commit was where the issue was introduced.
Suggest a fix
The mustache template should probably check to see if the User Agent variable was passed before generating it.
The text was updated successfully, but these errors were encountered: