Skip to content

fix: replace deprecated JSON encoding - #635

Open
NabDevs wants to merge 2 commits into
v11from
fix/guzzle-json-encoding
Open

fix: replace deprecated JSON encoding#635
NabDevs wants to merge 2 commits into
v11from
fix/guzzle-json-encoding

Conversation

@NabDevs

@NabDevs NabDevs commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Replaces deprecated GuzzleHttp\Utils::jsonEncode() calls with native json_encode(..., JSON_THROW_ON_ERROR) in the generated API clients and OpenAPI template.

Resolves INT-1795

@NabDevs
NabDevs requested a review from a team as a code owner August 7, 2026 09:09
Copilot AI lite review requested due to automatic review settings August 7, 2026 09:09
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.23%. Comparing base (5e7e49e) to head (5d55871).
⚠️ Report is 1 commits behind head on v11.

Additional details and impacted files
@@            Coverage Diff            @@
##                v11     #635   +/-   ##
=========================================
  Coverage     68.23%   68.23%           
  Complexity     1363     1363           
=========================================
  Files            83       83           
  Lines          3752     3752           
=========================================
  Hits           2560     2560           
  Misses         1192     1192           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes usage of the deprecated GuzzleHttp\Utils::jsonEncode() helper from generated PHP API clients by switching to native json_encode(..., JSON_THROW_ON_ERROR), and updates the OpenAPI generator template plus tests to enforce the change.

Changes:

  • Replace deprecated \GuzzleHttp\Utils::jsonEncode() calls in generated API request builders with json_encode(..., JSON_THROW_ON_ERROR).
  • Add test coverage to ensure generated clients no longer reference the deprecated helper and that invalid JSON payloads now throw JsonException.
  • Introduce/override the OpenAPI Generator api.mustache template to generate the new encoding behavior and document JsonException.

Reviewed changes

Copilot reviewed 2 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/Client/GeneratedJsonEncodingTest.php Adds a safety test to ensure generated API classes don’t contain deprecated Utils::jsonEncode calls.
test/Client/Generated/CoreApi/ShipmentApiPostShipmentsTest.php Adds a regression test asserting JsonException on invalid JSON payload encoding.
src/Client/Generated/OrderApi/Api/DefaultApi.php Replaces deprecated JSON encoding helper with native json_encode(..., JSON_THROW_ON_ERROR) and documents JsonException.
src/Client/Generated/IamApi/Api/DefaultApi.php Updates JSON encoding of form params to native json_encode(..., JSON_THROW_ON_ERROR) and documents JsonException.
src/Client/Generated/CoreApiPrivate/Api/ShippingRuleApi.php Updates JSON encoding of form params/body to native json_encode(..., JSON_THROW_ON_ERROR) and documents JsonException.
src/Client/Generated/CoreApi/Api/WebhookApi.php Updates JSON encoding of form params/body to native json_encode(..., JSON_THROW_ON_ERROR) and documents JsonException.
src/Client/Generated/CoreApi/Api/ShipmentApi.php Updates JSON encoding of form params/body to native json_encode(..., JSON_THROW_ON_ERROR) and documents JsonException.
src/Client/Generated/CoreApi/Api/NotificationApi.php Updates JSON encoding of form params/body to native json_encode(..., JSON_THROW_ON_ERROR) and documents JsonException.
src/Client/Generated/CoreApi/Api/DefaultApi.php Updates JSON encoding of form params to native json_encode(..., JSON_THROW_ON_ERROR) and documents JsonException.
openapi/templates/api.mustache Overrides generator template to emit native JSON encoding with JSON_THROW_ON_ERROR and add JsonException to docs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread openapi/templates/api.mustache Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants