Repository navigation
fix(specs): serialize empty object defaults as objects - #13544
Merged
Merged
Conversation
Contributor
Member
Author
|
@greptile review |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
loks0n
approved these changes
Sep 8, 2026
This was referenced Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix object-typed OpenAPI defaults being serialized as
[]instead of{}.Found during genuine Cloud spec verification for CLO-4377, tracked in Cloud #5716. This PR is independent of the optional-security migration in #13543 and branches directly from main.
Cause and fix
The object-specific formatter branches already normalize empty defaults to
stdClass, but the shared default assignment later overwrites the normalized value with the route's raw PHP[]. JSON then containstype: objectwithdefault: [], which fails strict OpenAPI validation.Normalize an exactly empty array to
stdClassat that shared assignment only when the final schema type isobject. Preserve default eligibility, array defaults, populated maps, scalar defaults, examples, and runtime API behavior.The captured Cloud document has 16 affected schemas, including screenshot headers, execution headers, presence metadata, and document/row update data. The published document has the same validation error; this was not introduced by the optional-security change.
Verification
arrayinstead ofstdClass) and pass afterward.{}, while populated maps, empty array schemas,0, andfalseremain unchanged.vendor/bin/phpunit tests/unit/SDK/Specification/FormatTest.php— passed: 38 tests, 210 assertions.vendor/bin/pint --test src/Appwrite/SDK/Specification/Format/OpenAPI3.php tests/unit/SDK/Specification/FormatTest.php— passed.composer refactor:check— passed across all 397 test files. The data provider now usesyield, fixing the failing CI Rector check.git diff --check— passed.{}JSON directly.Not run for this separate branch: full Cloud specs workflow, full-document strict validation, SDK regeneration/output comparisons, Appwrite runtime e2e, or full-project static analysis. This fixes the demonstrated object-default mismatch; it does not claim that the entire live spec is now validator-clean. No screenshots apply to this nonvisual formatter change.