Paul Krill
Editor at Large

Swift package plugin generates code from OpenAPI docs

news
Feb 1, 20242 mins

Swift OpenAPI Generator generates the Swift client or server code needed to make API calls or implement API servers.

shutterstock 2227591131 common Swift bird in flight over sunlit green grass
Credit: Per Grunditz / Shutterstock

Apple has released the stable 1.0 version of the Swift OpenAPI Generator 1.0, for generating Swift client and server code from an OpenAPI document, Swift developers announced on January 31.

Swift OpenAPI Generator generates the code needed to make API calls or implement API servers. The code is generated automatically at build time, so it is in sync with the OpenAPI document and does not need to be committed to a source repository. OpenAPI is an open standard for describing the behavior of HTTP services, and features an ecosystem of tools.

Swift OpenAPI Generator works with OpenAPI Specification versions 3.0 and 3.1. It supports streaming request and response bodies, backed by AsyncSequence, enabling use cases such as large payloads without buffering and JSON event streams. It supports common content types including JSON, URL-encoded form, Base64, plain text, and raw bytes, all of which are represented as value types with type-safe properties, and offers flexible client, server, and middleware abstractions, decoupling the generated code from the HTTP client library and web framework.

With Swift OpenAPI Generator, code can be generated to make type-safe requests to an API server with any HTTP client library. The plugin also can generate code to bootstrap an HTTP server with any web framework using business logic that is decoupled from network requests.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author