Fix incorrect JSON schema for FunctionCall and FunctionResponse#220
Fix incorrect JSON schema for FunctionCall and FunctionResponse#220felixarntz merged 3 commits intotrunkfrom
FunctionCall and FunctionResponse#220Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #220 +/- ##
============================================
+ Coverage 88.07% 88.11% +0.03%
- Complexity 1209 1212 +3
============================================
Files 60 60
Lines 3925 3928 +3
============================================
+ Hits 3457 3461 +4
+ Misses 468 467 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
gziolo
left a comment
There was a problem hiding this comment.
Looks good to me! The oneOf → anyOf fix is semantically correct and the FunctionResponse alignment with FunctionCall resolves a real inconsistency. Well tested.
| @@ -156,8 +169,8 @@ public static function fromArray(array $array): self | |||
| } | |||
|
|
|||
| return new self( | |||
There was a problem hiding this comment.
Non-blocking nitpick (caught by agent): this fromArray() now uses array_key_exists with a defensive (string) cast, while FunctionCall::fromArray() still uses $array[self::KEY_ID] ?? null. The difference is subtle — array_key_exists distinguishes between a missing key and a key explicitly set to null. Neither causes a real-world issue, but it's a minor inconsistency between two sibling classes doing the same thing.
FunctionCallandFunctionResponseare currently usingoneOf, which is not correct. It is totally valid for a function call or a function response to have bothidandnameset. So this needs to beanyOfinstead.FunctionResponsewas not handling itsidandnamethe same way asFunctionCall. The properties weren't nullable, even though they should be - only one is required, though both are allowed. This was already reflected in parts of the class, but not consistently.This PR fixes both of these bugs.