Hi everyone,
I’d like to pitch Swift OpenAPI Generator, and its support libraries, for the SSWG Incubation process at the Sandbox level.
Background
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.
Swift OpenAPI Generator is a SwiftPM plugin that takes an OpenAPI document and generates either the client code to perform HTTP calls or the server code to handle those calls. The generated code translates between a type‑safe representation of each operation’s input and output, and the underlying HTTP request and response.
Swift OpenAPI Generator is not tied to a specific client or server HTTP library; it allows plugging in custom libraries that provide the bridging code between the abstract representation defined in our runtime library, and the specific HTTP library. To learn more, check out the documentation.
Swift OpenAPI Generator was open sourced in May 2023 in a pre-1.0 state and continues development fully in the open. It was announced in a blog post on Swift.org and presented in Meet Swift OpenAPI Generator at WWDC 2023.
Usage of other SSWG libraries
Swift OpenAPI Generator uses the following SSWG-incubated libraries:
- OpenAPIKit to parse OpenAPI documents.
- AsyncHTTPClient in a transport implementation specific for AsyncHTTPClient.
Included packages
- apple/swift-openapi-generator – The package plugin, which performs code generation at build time.
- apple/swift-openapi-runtime – The runtime library, which contains protocol definitions used by the generated code and extension libraries.
- apple/swift-openapi-urlsession – A client transport that uses the URLSession type from the Foundation framework to perform HTTP operations.
- swift-server/swift-openapi-async-http-client – A client transport that uses the HTTPClient type from the AsyncHTTPClient library to perform HTTP operations.
- Other community transport implementations exist, and those can be pitched by their maintainers.
Usage
Please check out the announcement on Swift.org for how to adopt the plugin, and what the generated code looks like.
Conclusion
We’re looking for feedback on whether this project would fit into SSWG’s Incubation process in this thread, thanks!