Skip to content

Commit 8c075fc

Browse files
imonkiaalyx-dbjtreminio-dropbox
authored
Updating template files for Node SDK (#476)
Co-authored-by: Monica Auriemma <reta@dropbox.com> Co-authored-by: Juan Treminio <juantreminio@dropbox.com>
1 parent 23cb42f commit 8c075fc

20 files changed

Lines changed: 614 additions & 132 deletions

sdks/node/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.8-dev
1+
1.8.1-dev

sdks/node/api/apis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const queryParamsSerializer = (params) => {
3838
return Qs.stringify(params, { arrayFormat: "brackets" });
3939
};
4040

41-
export const USER_AGENT = "OpenAPI-Generator/1.8-dev/node";
41+
export const USER_AGENT = "OpenAPI-Generator/1.8.1-dev/node";
4242

4343
/**
4444
* Generates an object containing form data.

sdks/node/bin/copy-constants.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require_once __DIR__ . '/../vendor/autoload.php';
5+
6+
ini_set('display_errors', 1);
7+
ini_set('display_startup_errors', 1);
8+
error_reporting(E_ALL);
9+
10+
set_error_handler(function ($level, $msg) {
11+
echo "Error: {$msg}";
12+
exit(1);
13+
});
14+
15+
/**
16+
* Between openapi-generator v7.8.0 and v7.12.0 a change was made to the way
17+
* a few generators create constant names from values. The original way was
18+
* actually broken. For example "change-field-visibility" would generate a
19+
* constant name of "TYPE_FIELD_VISIBILITY", dropping the "change" part.
20+
*
21+
* The fix now generates the correct name, "TYPE_CHANGE_FIELD_VISIBILITY".
22+
* However, the fix also gets rid of the previous (incorrect) constant names,
23+
* making the fix a BC break.
24+
*
25+
* This simple script just adds the old constant names back, alongside the new
26+
* ones.
27+
*/
28+
class CopyConstants
29+
{
30+
public function run(): void
31+
{
32+
$file = __DIR__ . '/../model/subFormFieldRuleAction.ts';
33+
$contents = file_get_contents($file);
34+
35+
$constant_1 = ' ChangeFieldVisibility = "change-field-visibility",';
36+
$replace_1 = implode("\n", [
37+
$constant_1,
38+
' FieldVisibility = "change-field-visibility",',
39+
]);
40+
41+
$constant_2 = ' ChangeGroupVisibility = "change-group-visibility",';
42+
$replace_2 = implode("\n", [
43+
$constant_2,
44+
' GroupVisibility = "change-group-visibility",',
45+
]);
46+
47+
$contents = str_replace(
48+
$constant_1,
49+
$replace_1,
50+
$contents,
51+
);
52+
53+
$contents = str_replace(
54+
$constant_2,
55+
$replace_2,
56+
$contents,
57+
);
58+
59+
file_put_contents($file, $contents);
60+
}
61+
}
62+
63+
$copier = new CopyConstants();
64+
$copier->run();

0 commit comments

Comments
 (0)