fix(swift): generate valid inline union contract values - #109
Merged
Merged
Conversation
swiftTypedValue rendered every inline union as `[:]`. Inline unions are JSONValue in the Swift SDK, so the empty dictionary compiled, but Prism rejects it whenever the variants require fields. After the spec added ExternalObjectCreateInput.object / ExternalObjectUpdateInput.object (discriminated on `type`) and EvaluationEvaluationsInput.questions, 17 REST contract tests in archastro-swift got HTTP 422 instead of the documented status. Populate the first variant's required fields via generateDummyValue, as dc7b4b3 did for Go. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Review on ArchCode
Problem
Regenerate SDKin archastro-swift (#6) failsBuild + Test (macOS)→REST contract tests: 17 failures, all HTTP 422 from Prism.Affected:
ExternalObjectsContractTestscreate/update (12) andAiContractTestsai_evaluation_evaluations(5,questions: [[:]]). These tests are new with this spec refresh; Swiftmainlast regenerated in August.Go hit the same bug and was fixed in dc7b4b3; Swift never got the matching change.
What changed
swift-values.ts:case "union"→generateDummyValue(typeRef, fieldName, "swift"), which fills in the first variant's required fields. Same as Go'sgo-values.ts.unknownstill renders[:].JSONValue, which accepts dictionary, array, string, number, and boolean literals.Before → after (generated Swift test):
Scope / risk
Generator only (Swift contract-test fixtures). No SDK runtime or model output changes. Low risk.
Testing
swift.test.ts›populates inline union JSONValue inputs with a valid variant: failed before the fix (Received: "[:]"), passes after.npm test(sdk-generator): 425/425.tsc --noEmitandnpm run lintclean.ARCHASTRO_SDK_GENERATOR_BIN=… ./scripts/regenerate_sdk.sh --local <this checkout>in archastro-swift on theauto/regenerate-sdkhead, then ran the CI steps locally on macOS:prism mock specs/platform-openapi.json+swift test --skip-build --filter 'ArchAstroPlatformContractTests[.]'→ 1559 tests in 64 suites passed (previously 17 failures).ARCHASTRO_RUN_CHANNEL_CONTRACT_TESTS=1 swift test --filter 'ChannelContractTests|StreamContractTests|HarnessLifecycle'→ 81 tests in 9 suites passed.ApiChatChannelContractTestsoutput also changes with this fix and passes.CIruns the new vitest case on every PR. archastro-swiftCI(Build + Test (macOS)) runs the generated contract tests on each regen PR.Follow-up
Release sdk-generator v0.11.10 (
Releaseworkflow, patch), then rerunRegenerate SDKin archastro-swift.🤖 Generated with Claude Code