Skip to content

fix(sdk-generator): pass typed path params as strings in Go/Swift contract tests - #119

Merged
calvin-archastro merged 1 commit into
mainfrom
fix/contract-string-path-args
Oct 21, 2026
Merged

calvin-archastro merged 1 commit into
mainfrom
fix/contract-string-path-args

Conversation

@calvin-archastro

@calvin-archastro calvin-archastro commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review on ArchCode

Problem and author intent

The refreshed spec (#116) adds GET /api/v1/task_ownership_conversions/{job_id}, with job_id typed integer. 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 placeholder 1. As a result, the regeneration PRs fail CI:

  • archastro-go#13: go vet: cannot use 1 (untyped int constant) as string value in argument to client.V1.TaskOwnershipConversions.Get
  • archastro-swift#8: cannot 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.ts adds generatePathArgValue. For an integer, float or boolean parameter it returns the string form of the usual placeholder ("1"). Every other type goes through generateDummyValue as before. Prism accepts "1" for an integer path segment, since the URL carries the same characters.
  • contract-tests/go-emitter.ts and contract-tests/swift-emitter.ts use 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

  • New unit tests in __tests__/backends/value-generator.test.ts (generatePathArgValue). The full suite passes: 433 + 74.
    • One run had a single channel-harness failure, in the package this PR does not touch. It did not reproduce in 4 more full runs.
  • End-to-end, in scratch checkouts at origin/main with this branch's built generator (ARCHASTRO_SDK_GENERATOR_BIN=…/dist/index.js scripts/regenerate_sdk.sh --local):
    • archastro-go: gofmt -l is clean, and go vet, go build and go test ./... pass (contracttests 33.9s against Prism). The test now calls TaskOwnershipConversions.Get(ctx, "1").
    • archastro-swift: swift build --build-tests passes, and swift test --filter TaskOwnershipConversions passes 5/5 against Prism.

🤖 Generated with Claude Code

…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]>
@calvin-archastro
calvin-archastro merged commit 2ac6b14 into main Oct 21, 2026
2 checks passed
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.

1 participant