← 输入框|github.com|刷新
Skip to content

refactor(requests)!: serialize body parameters by value type, not by parameter name - #483

Merged
dargmuesli merged 2 commits into
betafrom
refactor/requests/type-based-serialization
Nov 3, 2026
Merged

dargmuesli merged 2 commits into
betafrom
refactor/requests/type-based-serialization

Conversation

@dargmuesli

Copy link
Copy Markdown
Member

The body serializer kept a per-name allow-list of body parameters whose stringified values should be re-parsed back into JSON. That list is why remove-playlist-items shipped broken in #478: items was not on it, so the JsonArray body went out as an escaped string, and the list itself only exists because of #421, which kept numeric-looking String values as strings. setBodyParameter now stores the value with its runtime type, and the serializer dispatches on that type: a JsonElement goes in as-is, a Boolean or Number as its literal, and everything else (in practice a String) as a JSON string. No per-name list to keep in sync, and a structured parameter can no longer silently become a string.

The two tests that called the serializer directly now build the body the way the client sends it, via initializeBody() and reading the entity, so they assert on what actually goes over the wire.

AbstractRequest.bodyParametersToJson(List), an internal serialization helper that is not part of IRequest, is now a private method; the wire format of every request is unchanged and getBodyParameters() still returns the same name/value strings, so only direct callers of that helper see a compile error. RemovePlaylistItemsExample now uses the Collection overload added in #482 instead of hand-building a JsonArray.

@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.28571% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.86%. Comparing base (3cedf7f) to head (8249484).

Files with missing lines Patch % Lines
...ichaelthelin/spotify/requests/AbstractRequest.java 94.28% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               beta     #483      +/-   ##
============================================
+ Coverage     46.70%   46.86%   +0.16%     
- Complexity      692      696       +4     
============================================
  Files           209      209              
  Lines          6276     6295      +19     
  Branches        759      764       +5     
============================================
+ Hits           2931     2950      +19     
+ Misses         2783     2781       -2     
- Partials        562      564       +2     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dargmuesli
dargmuesli marked this pull request as ready for review November 3, 2026 09:46
@dargmuesli
dargmuesli merged commit 2289ca1 into beta Nov 3, 2026
11 checks passed
@dargmuesli
dargmuesli deleted the refactor/requests/type-based-serialization branch November 3, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant