Skip to content

Commit 28146a6

Browse files
committed
Merge branch 'master' into fix-deno-anyOf-type
2 parents f50cc56 + ede6d39 commit 28146a6

File tree

35 files changed

+204
-48
lines changed

35 files changed

+204
-48
lines changed

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SDK/Language/CLI.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ public function getFiles()
158158
'template' => 'cli/lib/client.js.twig',
159159
'minify' => false,
160160
],
161+
[
162+
'scope' => 'default',
163+
'destination' => 'lib/utils.js',
164+
'template' => 'cli/lib/utils.js.twig',
165+
'minify' => false,
166+
],
161167
[
162168
'scope' => 'default',
163169
'destination' => 'lib/commands/init.js',

src/SDK/Language/Deno.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function getParamExample(array $param)
145145
$output .= '{}';
146146
break;
147147
case self::TYPE_FILE:
148-
$output .= "new File([fileBlob], 'file.png')";
148+
$output .= "'file.png'";
149149
break;
150150
}
151151
}
@@ -164,7 +164,7 @@ public function getParamExample(array $param)
164164
$output .= "'{$example}'";
165165
break;
166166
case self::TYPE_FILE:
167-
$output .= "new File([fileBlob], 'file.png')";
167+
$output .= "'file.png'";
168168
break;
169169
}
170170
}

src/SDK/Language/Kotlin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function getParamExample(array $param)
197197
if(empty($example) && $example !== 0 && $example !== false) {
198198
switch ($type) {
199199
case self::TYPE_FILE:
200-
$output .= 'File("./path-to-files/image.jpg")';
200+
$output .= 'File("file.png")';
201201
break;
202202
case self::TYPE_NUMBER:
203203
case self::TYPE_INTEGER:

src/SDK/Language/Node.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function getParamExample(array $param)
148148
$output .= '{}';
149149
break;
150150
case self::TYPE_FILE:
151-
$output .= "fs.createReadStream(__dirname + '/file.png')";
151+
$output .= "'file.png'";
152152
break;
153153
}
154154
}
@@ -167,11 +167,11 @@ public function getParamExample(array $param)
167167
$output .= "'{$example}'";
168168
break;
169169
case self::TYPE_FILE:
170-
$output .= "fs.createReadStream(__dirname + '/file.png')";
170+
$output .= "'file.png'";
171171
break;
172172
}
173173
}
174174

175175
return $output;
176176
}
177-
}
177+
}

src/SDK/Language/PHP.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public function getParamExample(array $param)
309309
$output .= '[]';
310310
break;
311311
case self::TYPE_FILE:
312-
$output .= "new \CURLFile('/path/to/file.png', 'image/png', 'file.png')";
312+
$output .= "'file.png'";
313313
break;
314314
}
315315
}
@@ -330,7 +330,7 @@ public function getParamExample(array $param)
330330
$output .= "'{$example}'";
331331
break;
332332
case self::TYPE_FILE:
333-
$output .= "new \CURLFile('/path/to/file.png', 'image/png', 'file.png')";
333+
$output .= "'file.png'";
334334
break;
335335
}
336336
}

src/SDK/Language/Python.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public function getParamExample(array $param)
302302
$output .= '{}';
303303
break;
304304
case self::TYPE_FILE:
305-
$output .= "open('/path/to/file.png', 'rb')"; //TODO add file class
305+
$output .= "'file.png'";
306306
break;
307307
}
308308
}
@@ -321,7 +321,7 @@ public function getParamExample(array $param)
321321
$output .= "'{$example}'";
322322
break;
323323
case self::TYPE_FILE:
324-
$output .= "open('/path/to/file.png', 'rb')"; //TODO add file class
324+
$output .= "'file.png'";
325325
break;
326326
}
327327
}

src/SDK/Language/Ruby.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public function getParamExample(array $param)
280280
$output .= '{}';
281281
break;
282282
case self::TYPE_FILE:
283-
$output .= "File.new()";
283+
$output .= "'dir/file.png'";
284284
break;
285285
}
286286
}
@@ -301,7 +301,7 @@ public function getParamExample(array $param)
301301
$output .= "'{$example}'";
302302
break;
303303
case self::TYPE_FILE:
304-
$output .= "File.new()";
304+
$output .= "'file.png'";
305305
break;
306306
}
307307
}

templates/cli/install.ps1.twig

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
$GITHUB_x64_URL = "https://github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName | caseDash }}/releases/download/{{ sdk.version }}/{{ language.params.executableName }}-cli-win-x64.exe"
1717
$GITHUB_arm64_URL = "https://github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName | caseDash }}/releases/download/{{ sdk.version }}/{{ language.params.executableName }}-cli-win-arm64.exe"
1818

19+
${{ spec.title | upper }}_BINARY_NAME = "{{ language.params.executableName }}.exe"
20+
1921
# {{ spec.title | caseUcfirst }} download directory
20-
${{ spec.title | upper }}_DOWNLOAD_DIR = Join-Path -Path $env:TEMP -ChildPath "{{ language.params.executableName }}.exe"
22+
${{ spec.title | upper }}_DOWNLOAD_DIR = Join-Path -Path $env:TEMP -ChildPath ${{ spec.title | upper }}_BINARY_NAME
2123

2224
# {{ spec.title | caseUcfirst }} CLI location
2325
${{ spec.title | upper }}_INSTALL_DIR = Join-Path -Path $env:LOCALAPPDATA -ChildPath "{{ spec.title | caseUcfirst }}"
24-
${{ spec.title | upper }}_INSTALL_FILE = Join-Path -Path ${{ spec.title | upper }}_INSTALL_DIR -ChildPath "{{ language.params.executableName }}.exe"
26+
${{ spec.title | upper }}_INSTALL_PATH = Join-Path -Path "${{ spec.title | upper }}_INSTALL_DIR" -ChildPath "${{ spec.title | upper }}_BINARY_NAME"
2527

2628
$USER_PATH_ENV_VAR = [Environment]::GetEnvironmentVariable("PATH", "User")
2729

@@ -53,9 +55,9 @@ function DownloadBinary {
5355
} else {
5456
Invoke-WebRequest -Uri $GITHUB_x64_URL -OutFile ${{ spec.title | upper }}_DOWNLOAD_DIR
5557
}
56-
57-
New-Item -ItemType Directory -Force -Path ${{ spec.title | upper }}_INSTALL_DIR | Out-Null
58-
Move-Item ${{ spec.title | upper }}_DOWNLOAD_DIR ${{ spec.title | upper }}_INSTALL_FILE
58+
59+
New-Item -ItemType Directory -Path ${{ spec.title | upper }}_INSTALL_DIR
60+
Move-Item ${{ spec.title | upper }}_DOWNLOAD_DIR ${{ spec.title | upper }}_INSTALL_PATH
5961
}
6062

6163

templates/cli/lib/client.js.twig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const os = require('os');
22
const axios = require("axios");
3+
const JSONbig = require("json-bigint")({ storeAsString: false });
34
const FormData = require("form-data");
45
const {{spec.title | caseUcfirst}}Exception = require("./exception.js");
56
const { globalConfig } = require("./config.js");
@@ -130,11 +131,9 @@ class Client {
130131
params: method.toUpperCase() === "GET" ? params : {},
131132
headers: headers,
132133
data:
133-
method.toUpperCase() === "GET" ||
134-
contentType.startsWith("multipart/form-data")
135-
? formData
136-
: params,
134+
method.toUpperCase() === "GET" || contentType.startsWith("multipart/form-data") ? formData : params,
137135
json: contentType.startsWith("application/json"),
136+
transformRequest: method.toUpperCase() === "GET" || contentType.startsWith("multipart/form-data") ? undefined : (data) => JSONbig.stringify(data),
138137
responseType: responseType,
139138
};
140139
try {

0 commit comments

Comments
 (0)