Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions templates/node/src/client.ts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ function fillDefaults(
result[key] = fillDefaults(result[key], child, models);
}
}
// The spread drops the non-enumerable JSON toString that Client.call attaches.
if (Object.prototype.hasOwnProperty.call(value, 'toString')) {
Object.defineProperty(result, 'toString', {
value: () => JSONbig.stringify(result),
writable: true,
enumerable: false,
configurable: true,
});
}
return result;
}

Expand Down
9 changes: 9 additions & 0 deletions templates/react-native/src/client.ts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ function fillDefaults(
result[key] = fillDefaults(result[key], child, models);
}
}
// The spread drops the non-enumerable JSON toString that Client.call attaches.
if (Object.prototype.hasOwnProperty.call(value, 'toString')) {
Object.defineProperty(result, 'toString', {
value: () => JSONbig.stringify(result),
writable: true,
enumerable: false,
configurable: true,
});
}
return result;
}

Expand Down
9 changes: 9 additions & 0 deletions templates/web/src/client.ts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ function fillDefaults(
result[key] = fillDefaults(result[key], child, models);
}
}
// The spread drops the non-enumerable JSON toString that Client.call attaches.
if (Object.prototype.hasOwnProperty.call(value, 'toString')) {
Object.defineProperty(result, 'toString', {
value: () => JSONbig.stringify(result),
writable: true,
enumerable: false,
configurable: true,
});
}
return result;
}

Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ abstract class Base extends TestCase
'preset: name=server, count=25, enabled=true',
];

protected const JS_MODEL_TO_STRING_RESPONSES = [
'preset toString: {"name":"guest","count":25,"enabled":false,"tier":"free"}',
];

protected const PYTHON_MODEL_DEFAULT_RESPONSES = [
'preset tier: PresetTier.FREE',
];
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/Node18Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ final class Node18Test extends Base
...Base::MODEL_RESPONSES,
...Base::OPTIONAL_PARAM_RESPONSES,
...Base::MODEL_DEFAULT_RESPONSES,
...Base::JS_MODEL_TO_STRING_RESPONSES,
...Base::EXCEPTION_RESPONSES,
...Base::OAUTH_RESPONSES,
...Base::QUERY_HELPER_RESPONSES,
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/Node20Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ final class Node20Test extends Base
...Base::MODEL_RESPONSES,
...Base::OPTIONAL_PARAM_RESPONSES,
...Base::MODEL_DEFAULT_RESPONSES,
...Base::JS_MODEL_TO_STRING_RESPONSES,
...Base::EXCEPTION_RESPONSES,
...Base::OAUTH_RESPONSES,
...Base::QUERY_HELPER_RESPONSES,
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/Node26Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ final class Node26Test extends Base
...Base::MODEL_RESPONSES,
...Base::OPTIONAL_PARAM_RESPONSES,
...Base::MODEL_DEFAULT_RESPONSES,
...Base::JS_MODEL_TO_STRING_RESPONSES,
...Base::EXCEPTION_RESPONSES,
...Base::OAUTH_RESPONSES,
...Base::QUERY_HELPER_RESPONSES,
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/ReactNativeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ final class ReactNativeTest extends Base
...Base::MODEL_RESPONSES,
...Base::OPTIONAL_PARAM_RESPONSES,
...Base::MODEL_DEFAULT_RESPONSES,
...Base::JS_MODEL_TO_STRING_RESPONSES,
...Base::EXCEPTION_RESPONSES,
...Base::REALTIME_RESPONSES,
...Base::QUERY_HELPER_RESPONSES,
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/WebChromiumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ final class WebChromiumTest extends Base
...Base::OPTIONAL_PARAM_RESPONSES,
...Base::UNION_RESPONSES,
...Base::MODEL_DEFAULT_RESPONSES,
...Base::JS_MODEL_TO_STRING_RESPONSES,
...Base::EXCEPTION_RESPONSES,
...Base::REALTIME_RESPONSES,
...Base::QUERY_HELPER_RESPONSES,
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/WebNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ final class WebNodeTest extends Base
...Base::OPTIONAL_PARAM_RESPONSES,
...Base::UNION_RESPONSES,
...Base::MODEL_DEFAULT_RESPONSES,
...Base::JS_MODEL_TO_STRING_RESPONSES,
...Base::EXCEPTION_RESPONSES,
...Base::QUERY_HELPER_RESPONSES,
...Base::PERMISSION_HELPER_RESPONSES,
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/languages/node/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ async function start() {
for (const item of presets.presets) {
console.log(`preset: name=${item.name}, count=${item.count}, enabled=${item.enabled}`);
}
console.log(`preset toString: ${preset.toString()}`);

try {
response = await general.error400();
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/languages/react-native/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ import {
for (const item of presets.presets) {
console.log(`preset: name=${item.name}, count=${item.count}, enabled=${item.enabled}`);
}
console.log(`preset toString: ${preset.toString()}`);

// Exception responses
try {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/languages/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@
for (const item of presets.presets) {
console.log(`preset: name=${item.name}, count=${item.count}, enabled=${item.enabled}`);
}
console.log(`preset toString: ${preset.toString()}`);

try {
response = await general.error400();
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/languages/web/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ async function start() {
for (const item of presets.presets) {
console.log(`preset: name=${item.name}, count=${item.count}, enabled=${item.enabled}`);
}
console.log(`preset toString: ${preset.toString()}`);

try {
response = await general.error400();
Expand Down
Loading