fix(swift): implement server-URL-templating support for multipleBaseUrls#16666
fix(swift): implement server-URL-templating support for multipleBaseUrls#16666devin-ai-integration[bot] wants to merge 1 commit into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
Description
Implements server-URL-templating (multiple base URLs) support in the Swift SDK generator, fixing the
server-url-templatingseed fixture so it compiles and passes. Removes that fixture fromallowedFailuresinseed/swift-sdk/seed.yml.Previously, the Swift generator only handled
singleBaseUrlenvironments. For APIs whose IR environments aremultipleBaseUrls(each environment exposes several server URLs keyed by base-URL ID, e.g.Basefor the API andAuthfor an auth service), generation was unsupported and the fixture was listed underallowedFailures.Changes Made
multipleBaseUrls, generate the environment as astructexposing oneStringURL per base-URL ID plus a static property per named environment, instead of theenumused forsingleBaseUrl. NewMultipleBaseUrlsEnvironmentGenerator; environment symbol registration now branches onenvironmentType(singleBaseUrl|multipleBaseUrls).RootClientGeneratorbuilds abaseUrlsmap (["Base": environment.base, "Auth": environment.auth]) and passes it toClientConfig. Each endpoint extracts itsendpoint.baseUrlid and threads it asbaseUrlId:intoperformRequest.ClientConfig.Template.swift,HTTPClient.Template.swift): added an optionalbaseUrls: [String: String]?toClientConfigand an optionalbaseUrlIdparameter through theperformRequest/buildRequest/buildRequestURLchain. URL construction now resolvesbaseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL. Both additions are backward-compatible (defaultnil), sosingleBaseUrlfixtures only pick up these additive lines.server-url-templating(and its now-orphaned explanatory comment) fromallowedFailuresinseed/swift-sdk/seed.yml.generators/swift/sdk/changes/unreleased/server-url-templating.yml(typefix).swift-sdkseed snapshots (shared-template additions are reflected across fixtures).Testing
pnpm run check(lint) passespnpm compile)swift:6.1.2Docker image (swift build,swift test— 20 tests pass)singleBaseUrlfixtures still build with the additive template changesLink to Devin session: https://app.devin.ai/sessions/a956152e78d145269d8833856c161476
Requested by: @iamnamananand996