{"id":13496802,"url":"https://github.com/apple/swift-openapi-generator","last_synced_at":"2026-01-16T07:39:32.325Z","repository":{"id":171110266,"uuid":"630566794","full_name":"apple/swift-openapi-generator","owner":"apple","description":"Generate Swift client and server code from an OpenAPI document.","archived":false,"fork":false,"pushed_at":"2025-04-16T14:02:04.000Z","size":1667,"stargazers_count":1603,"open_issues_count":92,"forks_count":128,"subscribers_count":116,"default_branch":"main","last_synced_at":"2025-05-03T20:02:46.833Z","etag":null,"topics":["ios-swift","openapi","plugin","server-side-swift","swift","swiftpm"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/apple/swift-openapi-generator/documentation","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apple.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-04-20T16:50:53.000Z","updated_at":"2025-05-03T01:01:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"905af3e9-47dc-4ce1-abfe-c5af7ac27bf7","html_url":"https://github.com/apple/swift-openapi-generator","commit_stats":{"total_commits":254,"total_committers":30,"mean_commits":8.466666666666667,"dds":"0.47637795275590555","last_synced_commit":"0eb9afaac4f4469e3111c8d0b984ce904c64c746"},"previous_names":["apple/swift-openapi-generator"],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-openapi-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-openapi-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-openapi-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-openapi-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apple","download_url":"https://codeload.github.com/apple/swift-openapi-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254069220,"owners_count":22009513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios-swift","openapi","plugin","server-side-swift","swift","swiftpm"],"created_at":"2024-07-31T19:02:00.224Z","updated_at":"2026-01-16T07:39:32.316Z","avatar_url":"https://github.com/apple.png","language":"Swift","funding_links":[],"categories":["Swift","Frameworks with plugins","Networking"],"sub_categories":[],"readme":"# Swift OpenAPI Generator\n\n[![](https://img.shields.io/badge/sswg-incubating-yellow.svg)](https://www.swift.org/sswg/)\n[![](https://img.shields.io/badge/docc-read_documentation-blue)](https://swiftpackageindex.com/apple/swift-openapi-generator/documentation)\n[![](https://img.shields.io/github/v/release/apple/swift-openapi-generator)](https://github.com/apple/swift-openapi-generator/releases)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fapple%2Fswift-openapi-generator%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/apple/swift-openapi-generator)\n\nGenerate Swift client and server code from an OpenAPI document.\n\n## Overview\n\n[OpenAPI][openapi] is a specification for documenting HTTP services. An OpenAPI document is written in either YAML or JSON, and can be read by tools to help automate workflows, such as generating the necessary code to send and receive HTTP requests.\n\nSwift OpenAPI Generator is a Swift package plugin that can generate the ceremony code required to make API calls, or implement API servers.\n\nThe code is generated at build-time, so it's always in sync with the OpenAPI document and doesn't need to be committed to your source repository.\n\n## Features\n\n- Works with OpenAPI Specification versions 3.0 and 3.1 and has preliminary support for version 3.2.\n- Streaming request and response bodies enabling use cases such as JSON event streams, and large payloads without buffering.\n- Support for JSON, multipart, URL-encoded form, base64, plain text, and raw bytes, represented as value types with type-safe properties.\n- Client, server, and middleware abstractions, decoupling the generated code from the HTTP client library and web framework.\n\nTo see these features in action, check out the list of [example projects][examples-generator].\n\n## Usage\n\nSwift OpenAPI Generator can be used to generate API clients and server stubs.\n\nBelow you can see some example code, or you can follow one of the [step-by-step tutorials][tutorials-generator].\n\n### Using a generated API client\n\nThe generated `Client` type provides a method for each HTTP operation defined in the OpenAPI document[^example-openapi-yaml] and can be used with any HTTP library that provides an implementation of `ClientTransport`.\n\n```swift\nimport OpenAPIURLSession\nimport Foundation\n\nlet client = Client(\n    serverURL: URL(string: \"http://localhost:8080/api\")!,\n    transport: URLSessionTransport()\n)\nlet response = try await client.getGreeting()\nprint(try response.ok.body.json.message)\n```\n\n### Using generated API server stubs\n\nTo implement a server, define a type that conforms to the generated `APIProtocol`, providing a method for each HTTP operation defined in the OpenAPI document[^example-openapi-yaml].\n\nThe server can be used with any web framework that provides an implementation of `ServerTransport`, which allows you to register your API handlers with the HTTP server.\n\n```swift\nimport OpenAPIRuntime\nimport OpenAPIVapor\nimport Vapor\n\nstruct Handler: APIProtocol {\n    func getGreeting(_ input: Operations.GetGreeting.Input) async throws -\u003e Operations.GetGreeting.Output {\n        let name = input.query.name ?? \"Stranger\"\n        return .ok(.init(body: .json(.init(message: \"Hello, \\(name)!\"))))\n    }\n}\n\n@main struct HelloWorldVaporServer {\n    static func main() async throws {\n        let app = try await Application.make()\n        let transport = VaporTransport(routesBuilder: app)\n        let handler = Handler()\n        try handler.registerHandlers(on: transport, serverURL: URL(string: \"/api\")!)\n        try await app.execute()\n    }\n}\n```\n\n## Package ecosystem\n\nThe Swift OpenAPI Generator project is split across multiple repositories to enable extensibility and minimize dependencies in your project.\n\n| Repository                                                 | Description                                        |\n| ----------                                                 | -----------                                        |\n| [apple/swift-openapi-generator][repo-generator]            | Swift package plugin and CLI                       |\n| [apple/swift-openapi-runtime][repo-runtime]                | Runtime library used by the generated code         |\n| [apple/swift-openapi-urlsession][repo-urlsession]          | `ClientTransport` using [URLSession][urlsession]   |\n| [swift-server/swift-openapi-async-http-client][repo-ahc]   | `ClientTransport` using [AsyncHTTPClient][ahc]     |\n| [vapor/swift-openapi-vapor][repo-vapor]                    | `ServerTransport` using [Vapor][vapor]             |\n| [hummingbird-project/swift-openapi-hummingbird][repo-hb]   | `ServerTransport` using [Hummingbird][hb]          |\n| [awslabs/swift-openapi-lambda][repo-lambda]                | `ServerTransport` using [AWS Lambda][lambda]       |\n\n## Requirements and supported features\n\n| Generator versions | Supported OpenAPI versions  |\n| ------------------ | --------------------------- |\n| `1.0.0` ... `main` | 3.0, 3.1, 3.2 (preliminary) |\n\nSee also [Supported OpenAPI features][supported-openapi-features].\n\n### Supported platforms and minimum versions\n\nThe generator is used during development and is supported on macOS, Linux, and Windows.\n\nThe generated code, runtime library, and transports are supported on more\nplatforms, listed below.\n\n| Component                           | macOS     | Linux, Windows | iOS    | tvOS   | watchOS | visionOS | Android |\n| ----------------------------------: | :---      | :------------  | :-     | :--    | :-----  | :------  | :------ |\n| Generator plugin and CLI            | ✅ 10.15+ | ✅              | ✖️     | ✖️     | ✖️      | ✖️        | ✖️      |\n| Generated code and runtime library  | ✅ 10.15+ | ✅              | ✅ 13+ | ✅ 13+ | ✅ 6+   | ✅ 1+     | ✅      |\n\n## Documentation and example projects\n\nTo get started, check out the [documentation][docs-generator], which contains\n[step-by-step tutorials][tutorials-generator].\n\nYou can also experiment with [example projects][examples-generator] that use\nSwift OpenAPI Generator and integrate with other packages in the ecosystem.\n\nOr if you prefer to watch a video, check out [Meet Swift OpenAPI\nGenerator](https://developer.apple.com/wwdc23/10171) from WWDC23.\n\n[openapi]: https://openapis.org\n[repo-generator]: https://github.com/apple/swift-openapi-generator\n[docs-generator]: https://swiftpackageindex.com/apple/swift-openapi-generator/documentation\n[tutorials-generator]: https://swiftpackageindex.com/apple/swift-openapi-generator/tutorials/swift-openapi-generator\n[supported-openapi-features]: https://swiftpackageindex.com/apple/swift-openapi-generator/documentation/swift-openapi-generator/supported-openapi-features\n[examples-generator]: https://github.com/apple/swift-openapi-generator/blob/main/Examples/README.md\n[repo-runtime]: https://github.com/apple/swift-openapi-runtime\n[repo-urlsession]: https://github.com/apple/swift-openapi-urlsession\n[urlsession]: https://developer.apple.com/documentation/foundation/urlsession\n[repo-ahc]: https://github.com/swift-server/swift-openapi-async-http-client\n[ahc]: https://github.com/swift-server/async-http-client\n[repo-vapor]: https://github.com/vapor/swift-openapi-vapor\n[vapor]: https://github.com/vapor/vapor\n[repo-hb]: https://github.com/hummingbird-project/swift-openapi-hummingbird\n[hb]: https://github.com/hummingbird-project/hummingbird\n[repo-lambda]: https://github.com/awslabs/swift-openapi-lambda\n[lambda]: https://docs.aws.amazon.com/lambda/latest/dg/welcome.html\n[^example-openapi-yaml]: \u003cdetails\u003e\u003csummary\u003eExample OpenAPI document (click to expand)\u003c/summary\u003e\n\n    ```yaml\n    openapi: '3.1.0'\n    info:\n      title: GreetingService\n      version: 1.0.0\n    servers:\n      - url: https://example.com/api\n        description: Example service deployment.\n    paths:\n      /greet:\n        get:\n          operationId: getGreeting\n          parameters:\n            - name: name\n              required: false\n              in: query\n              description: The name used in the returned greeting.\n              schema:\n                type: string\n          responses:\n            '200':\n              description: A success response with a greeting.\n              content:\n                application/json:\n                  schema:\n                    $ref: '#/components/schemas/Greeting'\n    components:\n      schemas:\n        Greeting:\n          type: object\n          description: A value with the greeting contents.\n          properties:\n            message:\n              type: string\n              description: The string representation of the greeting.\n          required:\n            - message\n    ```\n    \u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapple%2Fswift-openapi-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapple%2Fswift-openapi-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapple%2Fswift-openapi-generator/lists"}