Repository navigation
fix(sdk-generator): pass typed path params as strings in Go/Swift contract tests - #119
Merged
Merged
Conversation
…tract tests
The refreshed spec adds GET /api/v1/task_ownership_conversions/{job_id}
with an integer job_id. The Go and Swift SDKs type every path and scope
argument as a string, but their contract-test emitters passed the
schema-typed placeholder 1, so the regenerated tests fail to compile
(go vet / swiftc). generatePathArgValue renders integer, float and boolean
path/scope placeholders as their string form ("1"), which Prism accepts
for the typed segment.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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 and author intent
The refreshed spec (#116) adds
GET /api/v1/task_ownership_conversions/{job_id}, withjob_idtypedinteger. It is the first non-string path parameter in the platform spec. The Go and Swift SDK emitters always type path and scope arguments as strings (go/resource-emitter.ts:429-430,swift/resource-emitter.ts:425-426). Their contract-test emitters, however, pass the schema-typed placeholder1. As a result, the regeneration PRs fail CI:go vet:cannot use 1 (untyped int constant) as string value in argument to client.V1.TaskOwnershipConversions.Getcannot convert value of type 'Int' to expected argument type 'String'(5 sites)The goal is for the Go and Swift contract tests to call the SDK with the type its signature declares.
What changed
value-generator.tsaddsgeneratePathArgValue. For an integer, float or boolean parameter it returns the string form of the usual placeholder ("1"). Every other type goes throughgenerateDummyValueas before. Prism accepts"1"for an integer path segment, since the URL carries the same characters.contract-tests/go-emitter.tsandcontract-tests/swift-emitter.tsuse it for scope and path arguments. Query parameters are unchanged, because those are typed in the SDKs.Unchanged: the SDK signatures, so this is not a public API change. The TypeScript, Python, Rust and Elixir emitters are untouched; their regenerations already pass.
Scope: generator, contract-test output only.
Risk: low.
User impact: none.
Testing
__tests__/backends/value-generator.test.ts(generatePathArgValue). The full suite passes: 433 + 74.ARCHASTRO_SDK_GENERATOR_BIN=…/dist/index.js scripts/regenerate_sdk.sh --local):gofmt -lis clean, andgo vet,go buildandgo test ./...pass (contracttests 33.9s against Prism). The test now callsTaskOwnershipConversions.Get(ctx, "1").swift build --build-testspasses, andswift test --filter TaskOwnershipConversionspasses 5/5 against Prism.🤖 Generated with Claude Code