Skip to content

Preserve empty JSON schema object maps#234

Open
chubes4 wants to merge 2 commits into
WordPress:trunkfrom
chubes4:fix-json-schema-object-map-serialization
Open

Preserve empty JSON schema object maps#234
chubes4 wants to merge 2 commits into
WordPress:trunkfrom
chubes4:fix-json-schema-object-map-serialization

Conversation

@chubes4
Copy link
Copy Markdown

@chubes4 chubes4 commented May 9, 2026

Summary

  • Adds a JSON-serializable parameter accessor for FunctionDeclaration that preserves empty JSON Schema object-map fields as {}.
  • Updates FunctionDeclaration::jsonSerialize() to use the safe parameter representation.
  • Updates the shared OpenAI-compatible tool payload builder to use the safe parameter representation when embedding function declarations.

Fixes #233.

Testing

  • vendor/bin/phpunit tests/unit/Tools/DTO/FunctionDeclarationTest.php --filter testJsonSerializationPreservesEmptySchemaObjectMaps
  • vendor/bin/phpunit tests/unit/Providers/OpenAiCompatibleImplementation/AbstractOpenAiCompatibleTextGenerationModelTest.php --filter testPrepareToolsParamPreservesEmptySchemaObjectMaps
  • vendor/bin/phpunit tests/unit/Tools/DTO/FunctionDeclarationTest.php
  • vendor/bin/phpunit tests/unit/Providers/OpenAiCompatibleImplementation/AbstractOpenAiCompatibleTextGenerationModelTest.php
  • composer phpcs
  • composer phpstan

AI assistance

  • AI assistance: Yes
  • Tool(s): OpenCode (GPT-5.5)
  • Used for: Drafted the focused serialization fix and tests from the issue reproduction; Chris remains responsible for review and merge.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: chubes4 <extrachill@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.21%. Comparing base (6317042) to head (824774d).

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk     #234      +/-   ##
============================================
+ Coverage     88.12%   88.21%   +0.08%     
- Complexity     1213     1225      +12     
============================================
  Files            60       60              
  Lines          3934     3963      +29     
============================================
+ Hits           3467     3496      +29     
  Misses          467      467              
Flag Coverage Δ
unit 88.21% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

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.

Preserve empty JSON Schema object maps in FunctionDeclaration parameters

1 participant