Swift OpenAPI Generator is an Apple-maintained Swift package plugin that automates the generation of Swift client and server code from OpenAPI documents. The tool reads OpenAPI specifications written in YAML or JSON and generates the necessary ceremony code to make API calls or implement API servers, eliminating the need to manually write boilerplate HTTP handling code. Code generation occurs at build-time, ensuring the generated code remains synchronized with the OpenAPI document without requiring commits to the source repository.
The generator supports OpenAPI Specification versions 3.0 and 3.1, with preliminary support for version 3.2. It provides comprehensive support for multiple content types including JSON, multipart, URL-encoded form, base64, plain text, and raw bytes, all represented as type-safe value types with strongly-typed properties. A notable feature is support for streaming request and response bodies, enabling use cases such as JSON event streams and handling large payloads without buffering them entirely in memory. The architecture employs client, server, and middleware abstractions that decouple generated code from specific HTTP client libraries and web frameworks, providing flexibility in implementation choices.
The project is structured across multiple repositories to enable extensibility and minimize dependencies. The core generator repository contains the Swift package plugin and command-line interface. The ecosystem includes a runtime library used by generated code, transport implementations for various HTTP clients and frameworks such as URLSession, AsyncHTTPClient, OkHttp, Vapor, Hummingbird, and AWS Lambda, allowing developers to choose their preferred networking and server solutions.
According to GitGenius activity tracking, the repository has processed 229 issues and pull requests with a median response latency of 0.0 hours and a mean latency of 1317.1 hours, indicating rapid initial triage followed by longer resolution times for complex issues. The most active labels are status/triage with 124 occurrences, kind/support with 65 occurrences, and kind/bug with 54 occurrences. The primary contributor, czechboy0, has logged 694 events, followed by simonjbeaumont with 159 events and alteredtech with 56 events. The repository shares contributors with microsoft/vscode, swiftlang/swift, and microsoft/typescript, indicating cross-ecosystem involvement.
Platform support is extensive for generated code and runtime components, covering macOS 10.15 and later, Linux, Windows, iOS 13 and later, tvOS 13 and later, watchOS 6 and later, visionOS 1 and later, and Android. The generator plugin itself runs on macOS, Linux, and Windows during development. The project provides comprehensive documentation including step-by-step tutorials and example projects demonstrating integration with other ecosystem packages. A WWDC23 presentation titled "Meet Swift OpenAPI Generator" offers video-based introduction to the tool's capabilities and usage patterns.