Skip to content

fix(swift): implement server-URL-templating support for multipleBaseUrls#16666

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782201111-swift-server-url-templating
Open

fix(swift): implement server-URL-templating support for multipleBaseUrls#16666
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782201111-swift-server-url-templating

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Description

Implements server-URL-templating (multiple base URLs) support in the Swift SDK generator, fixing the server-url-templating seed fixture so it compiles and passes. Removes that fixture from allowedFailures in seed/swift-sdk/seed.yml.

Previously, the Swift generator only handled singleBaseUrl environments. For APIs whose IR environments are multipleBaseUrls (each environment exposes several server URLs keyed by base-URL ID, e.g. Base for the API and Auth for an auth service), generation was unsupported and the fixture was listed under allowedFailures.

Changes Made

  • Environment as a struct: For multipleBaseUrls, generate the environment as a struct exposing one String URL per base-URL ID plus a static property per named environment, instead of the enum used for singleBaseUrl. New MultipleBaseUrlsEnvironmentGenerator; environment symbol registration now branches on environmentType (singleBaseUrl | multipleBaseUrls).
    public struct ApiEnvironment: Equatable, Sendable {
        public let base: String
        public let auth: String
        public static let regionalApiServer = ApiEnvironment(
            base: "https://api.example.com/v1", auth: "https://auth.example.com")
    }
  • Per-endpoint base-URL routing: RootClientGenerator builds a baseUrls map (["Base": environment.base, "Auth": environment.auth]) and passes it to ClientConfig. Each endpoint extracts its endpoint.baseUrl id and threads it as baseUrlId: into performRequest.
  • Shared templates (ClientConfig.Template.swift, HTTPClient.Template.swift): added an optional baseUrls: [String: String]? to ClientConfig and an optional baseUrlId parameter through the performRequest / buildRequest / buildRequestURL chain. URL construction now resolves baseUrlId.flatMap { clientConfig.baseUrls?[$0] } ?? clientConfig.baseURL. Both additions are backward-compatible (default nil), so singleBaseUrl fixtures only pick up these additive lines.
  • Removed server-url-templating (and its now-orphaned explanatory comment) from allowedFailures in seed/swift-sdk/seed.yml.
  • Added changelog entry generators/swift/sdk/changes/unreleased/server-url-templating.yml (type fix).
  • Regenerated all swift-sdk seed snapshots (shared-template additions are reflected across fixtures).

Testing

  • pnpm run check (lint) passes
  • TypeScript compiles (pnpm compile)
  • Swift build + tests pass for the fixture via swift:6.1.2 Docker image (swift build, swift test — 20 tests pass)
  • Verified representative singleBaseUrl fixtures still build with the additive template changes
  • Manual testing completed

Link to Devin session: https://app.devin.ai/sessions/a956152e78d145269d8833856c161476
Requested by: @iamnamananand996

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@github-actions

Copy link
Copy Markdown
Contributor

SDK Generation Benchmark Results

Comparing PR branch against median of 5 nightly run(s) on main (latest: 2026-06-23T05:19:28Z).

Full benchmark table (click to expand)
Generator Spec main (generator) main (E2E) PR (generator) Delta
swift-sdk square 58s (n=5) 431s (n=5) 60s +2s (+3.4%)

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 fern generate). main (E2E): full customer-observable time including build/test scripts (nightly baseline, informational). Delta is computed against generator-only baseline.
⚠️ = generation exited with a non-zero exit code (timing may not reflect a successful run).
Baseline from nightly runs on main (latest: 2026-06-23T05:19:28Z). Trigger benchmark-baseline to refresh.
Last updated: 2026-06-23 12:06 UTC

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