You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Default missing required collections when filling response defaults #2017
Goal: When a response omits a required collection field that the spec gives no default, generated SDK models should fill it with an empty list instead of leaving it undefined (JS TypeError) or throwing (PHP Missing required field "presets"). Follow-up to #2007 (spec defaults for missing model fields).
src/SDK/Language.php: new getModelDefault() returns the spec default for a required field, or [] for a required array schema with no default; optional fields and nested models stay absent.
src/SDK/SDK.php: new modelDefault Twig filter; emitters in src/SDK/Language/ (Dart, DotNet, JS, Kotlin, Ruby, Rust, Swift) read defaults through it (Rust's old helper renamed to getRustDefault).
Model templates for Dart, .NET, PHP, Python, Ruby, Rust and Swift switch from schemaDefault to modelDefault. Go is unchanged, since a nil slice already reads as empty.
Tests: new mock GET /v1/mock/tests/general/presets/empty returning {"total": 0} in mock-server/app/http.php, tests/resources/spec-openapi3.json, tests/generation/GenerationTest.php, and e2e checks in every language under tests/e2e/languages/ expecting empty presets: 0.
Remaining steps: None beyond review and merge; the linked PR is the full change.
E2E listEmptyPresets prints empty presets: 0 for every SDK on CI
Update (2026-10-13): Related fix #2020 (merged) keeps the JSON toString on JS responses after fillDefaults spreads in model defaults, in templates/web/src/client.ts.twig, templates/node/src/client.ts.twig and templates/react-native/src/client.ts.twig, with e2e checks under tests/e2e/.
Activity