SDK generation

Generate a Swift SDK from OpenAPI: end-to-end in 2026

Use Apple's swift-openapi-generator to generate a Swift SDK from OpenAPI in 2026. It's Apple's own official generator, actively maintained (v1.13.1, released September 1, 2026), integrates as a Swift Package Manager build plugin, and supports OpenAPI 3.0 and 3.1 with preliminary 3.2 support. The other commonly cited option, CreateAPI, has had no commits since October 2023 and no release since May 2023 — treat it as unmaintained. OpenAPI Generator also has swift5/swift6 templates as a third option. Sourced doesn't generate a Swift SDK — see "Where Sourced fits" below for what it does cover.

Swift SDK generators compared

Tool Maintained (Sept 2026) Type Best for
swift-openapi-generator (Apple) Yes — v1.13.1, released Sept 1 2026 SPM build plugin, generates at build time The default choice for nearly everyone in 2026
CreateAPI No — last commit Oct 2023, last release (0.2.0) May 2023 CLI / SPM plugin, checked-in generated code Legacy projects already using it; not for new adoption
OpenAPI Generator (swift5 / swift6) Yes — v7.25.0, released Aug 24 2026 Traditional codegen, checked-in output Teams standardizing on OpenAPI Generator across many languages

Option 1: Apple's swift-openapi-generator (recommended)

This is Apple's own project (sswg incubating status in the Swift Server Workgroup), introduced at WWDC23 and still actively released — the latest version, 1.13.1, shipped September 1, 2026. It works as a Swift Package Manager build plugin: code generates at build time from your OpenAPI document, so it's never committed to source and never drifts out of sync with the spec you're building against.

Add the generator, runtime, and a transport to Package.swift:

// swift-tools-version:6.1
import PackageDescription

let package = Package(
    name: "MyAPIClient",
    platforms: [.macOS(.v10_15), .iOS(.v13)],
    dependencies: [
        .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
        .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
        .package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
    ],
    targets: [
        .target(
            name: "MyAPIClient",
            dependencies: [
                .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
                .product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
            ],
            plugins: [.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator")]
        )
    ]
)

Then drop two files into your target's source directory (e.g. Sources/MyAPIClient/):

# openapi-generator-config.yaml
generate:
  - types
  - client
accessModifier: internal

Put your spec alongside it as openapi.yaml (or .json). Build the target and the plugin generates Client and the request/response types automatically — nothing to check in, nothing to re-run manually when the spec changes.

import OpenAPIURLSession

let client = Client(
    serverURL: URL(string: "https://api.example.com")!,
    transport: URLSessionTransport()
)
let response = try await client.getGreeting()

Swap URLSessionTransport for AsyncHTTPClientTransport (Linux/server-side Swift) or a Vapor/Hummingbird server transport if you're generating server stubs instead of a client — the same generator does both.

Option 2: CreateAPI (stale — not recommended for new projects)

CreateAPI was a well-regarded Swift-native OpenAPI generator, but as of September 2026 it shows no commits since October 17, 2023, and its latest tagged release (0.2.0) dates to May 15, 2023 — over three years old with no sign of continued maintenance. There's no formal "archived" banner on the repo, but the activity record speaks for itself. Don't start a new project on it; if you have an existing CreateAPI-generated client, budget time to migrate to Apple's generator rather than depending on an inactive project for OpenAPI 3.1 or newer Swift toolchain compatibility.

Option 3: OpenAPI Generator (swift5 / swift6)

OpenAPI Generator, the same multi-language project covered elsewhere on this blog, ships two Swift generator names: swift5 and the newer swift6. Actively maintained (v7.25.0, released August 24, 2026), it's a reasonable choice if you're already running OpenAPI Generator for other languages and want one config format and one CI step across your whole SDK fleet.

npx @openapitools/openapi-generator-cli generate \
  -i ./openapi.yaml \
  -g swift6 \
  -o ./generated

Unlike Apple's plugin-based approach, this produces checked-in generated source rather than build-time codegen — useful if your build environment can't run SPM plugins, less convenient if you want the SDK to always match the spec you're compiling against.

Which one should you use

Apple's swift-openapi-generator, for nearly everyone. It's official, actively released, integrates cleanly with SPM, and generates at build time so the SDK can't silently drift from the spec. Reach for OpenAPI Generator's swift5/swift6 only if you need checked-in generated code or are standardizing tooling across many languages. Don't start new work on CreateAPI — it's been dormant since 2023.

Whichever you pick, spec quality still decides output quality: every operation needs an operationId, schemas belong in components/schemas, and security schemes need to be defined. See OpenAPI best practices for SDK-friendly specs, or run Sourced's OpenAPI validator before generating.

Where Sourced fits (and doesn't)

Plainly: Sourced's generated SDKs focus on TypeScript and Python today — the two ecosystems where teams publish first. If Swift is your target, generate it with Apple's swift-openapi-generator above, and bring Sourced in for the part of the workflow it does own: docs, llms.txt, and validation on the same spec.

What's language-independent and works from the same OpenAPI spec you're feeding to any of these Swift tools:

  • Hosted docs, generated from your spec, free to try with a private preview URL — no separate docs pipeline for your iOS/macOS API surface.
  • llms.txt generationllms-txt generator — so LLM agents can read your API surface directly.
  • OpenAPI validation that catches the spec issues that produce bad Swift output before any generator runs — openapi-validator.
  • Spec diffing between versions, so a breaking API change doesn't surprise your Swift client at runtime — openapi-diff.

Generate your Swift SDK with swift-openapi-generator; give the same spec to Sourced for free hosted docs, llms.txt, and validation in one pass. Create hosted docs from your repo or start free — unlimited previews, up to 2 hosted noindex docs review sites and one hosted MCP server, no credit card.

Generating SDKs in other languages

Same spec, different target language — see TypeScript, Python, PHP, Rust, Kotlin, Go, Java, C#, and Ruby.

FAQ

Does Sourced generate Swift SDKs?

No — see "Where Sourced fits" above for what Sourced covers instead. For Swift, use Apple's swift-openapi-generator, covered above.

Is CreateAPI safe to use for a new Swift project in 2026?

No — as of September 2026, CreateAPI has had no commits since October 2023 and no release since May 2023. Use Apple's swift-openapi-generator instead; it's actively maintained and officially supported.

Does Apple's generator support OpenAPI 3.1?

Yes. As of the current release, swift-openapi-generator supports OpenAPI Specification versions 3.0 and 3.1, with preliminary support for 3.2.

Do I need to commit the generated Swift code?

No, and that's a deliberate design choice — swift-openapi-generator runs as a build plugin and generates code at build time, so it's always in sync with your spec and doesn't need to live in source control. OpenAPI Generator's swift5/swift6 templates work the traditional way instead, producing checked-in output.

Can I generate both a client and a server with the same tool?

Yes, with Apple's swift-openapi-generator. The same generator config produces client code (paired with a ClientTransport like URLSessionTransport) or server stub code (implementing APIProtocol, paired with a ServerTransport like Vapor or Hummingbird), depending on what you request in openapi-generator-config.yaml.

Can I use Sourced for Swift API docs even though Sourced's SDK generation stops at TypeScript and Python?

Yes. Point Sourced at the same OpenAPI spec you're using with swift-openapi-generator, and it produces hosted docs, llms.txt, and spec validation independent of which language's SDK you generate from that spec.