Skip to content

Commit

Permalink
Fix process is not defined for browser use cases, Fix webpack polyfil…
Browse files Browse the repository at this point in the history
…l issue, deprecate usage of node.js query string, Update Swagger Codegen version to v3.0.52, update sample code
  • Loading branch information
jv-asana committed Jan 19, 2024
1 parent ffaeaf8 commit 3ddbee9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
java-version: "17"
- name: Setup environment variables
run: |
echo "generator_version=3.0.46" >> "$GITHUB_ENV"
echo "generator_version=3.0.52" >> "$GITHUB_ENV"
echo "generator_name=swagger-codegen-cli.jar" >> "$GITHUB_ENV"
echo "jar_asana=codegen/swagger/target/AsanaClientCodegen-swagger-codegen-1.0.0.jar" >> "$GITHUB_ENV"
echo "actual_lang=com.asana.codegen.JavascriptClientCodegenGenerator" >> "$GITHUB_ENV"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void setParameterExampleValue(CodegenParameter p) {
// Update example for requests that require body
if (!languageSpecificPrimitives.contains(type)) {
// type is a model class, e.g. User
p.example = "{\"data\": {\"param1\": \"value1\", \"param2\": \"value2\",}}";
p.example = "{\"data\": {\"<PARAM_1>\": \"<VALUE_1>\", \"<PARAM_2>\": \"<VALUE_2>\",}}";
p.dataType = "Object";
}
}
Expand Down
28 changes: 18 additions & 10 deletions codegen/templates/ApiClient.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{>licenseInfo}}
import superagent from "superagent";
import querystring from "querystring";

{{#emitJSDoc}}/**
* @module {{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient
Expand Down Expand Up @@ -420,14 +419,23 @@ export class ApiClient {
request.query(this.normalizeParams(queryParams));
// set header parameters
headerParams['X-Asana-Client-Lib'] = querystring.stringify(
{
'version': "{{projectVersion}}",
'language': 'NodeJS',
'language_version': process.version,
'os': process.platform
}
);
if (typeof(navigator) === 'undefined' || typeof(window) === 'undefined') {
headerParams['X-Asana-Client-Lib'] = new URLSearchParams(
{
'version': "{{projectVersion}}",
'language': 'NodeJS',
'language_version': process.version,
'os': process.platform
}
).toString();
} else {
headerParams['X-Asana-Client-Lib'] = new URLSearchParams(
{
'version': "{{projectVersion}}",
'language': 'BrowserJS'
}
).toString();
}
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
// set requestAgent if it is set by user
Expand All @@ -449,7 +457,7 @@ export class ApiClient {
}
if (contentType === 'application/x-www-form-urlencoded') {
request.send(querystring.stringify(this.normalizeParams(formParams)));
request.send(new URLSearchParams(this.normalizeParams(formParams)).toString());
} else if (contentType == 'multipart/form-data') {
var _formParams = this.normalizeParams(formParams);
for (var key in _formParams) {
Expand Down

0 comments on commit 3ddbee9

Please sign in to comment.