Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apple/swift-openapi-runtime
API package for code generated by Swift OpenAPI Generator.
https://github.com/apple/swift-openapi-runtime
middleware openapi swift transport
Last synced: 27 days ago
JSON representation
API package for code generated by Swift OpenAPI Generator.
- Host: GitHub
- URL: https://github.com/apple/swift-openapi-runtime
- Owner: apple
- License: apache-2.0
- Created: 2023-04-20T16:52:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-07T16:20:29.000Z (about 2 months ago)
- Last Synced: 2024-09-29T21:41:23.153Z (about 1 month ago)
- Topics: middleware, openapi, swift, transport
- Language: Swift
- Homepage: https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation
- Size: 438 KB
- Stars: 179
- Watchers: 97
- Forks: 38
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Swift OpenAPI Generator Runtime
[![](https://img.shields.io/badge/docc-read_documentation-blue)](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation)
[![](https://img.shields.io/github/v/release/apple/swift-openapi-runtime)](https://github.com/apple/swift-openapi-runtime/releases)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fapple%2Fswift-openapi-runtime%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/apple/swift-openapi-runtime)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fapple%2Fswift-openapi-runtime%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/apple/swift-openapi-runtime)This library provides common abstractions and helper functions used by the client and server code generated by [Swift OpenAPI Generator][0].
## Overview
It contains:
- Common types used in the code generated by the `swift-openapi-generator` package plugin.
- Protocol definitions for pluggable layers, including [`ClientTransport`](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation/openapiruntime/clienttransport), [`ServerTransport`](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation/openapiruntime/servertransport), [`ClientMiddleware`](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation/openapiruntime/clientmiddleware), and [`ServerMiddleware`](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation/openapiruntime/servermiddleware).Many of the HTTP currency types used are defined in the [Swift HTTP Types](https://github.com/apple/swift-http-types) library.
> Tip: Check out the [example projects](https://swiftpackageindex.com/apple/swift-openapi-generator/documentation/swift-openapi-generator/checking-out-an-example-project) focused on middlewares.
## Usage
Add the package dependency in your `Package.swift`:
```swift
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
```Next, in your target, add `OpenAPIRuntime` to your dependencies:
```swift
.target(name: "MyTarget", dependencies: [
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
]),
```The next step depends on your use case.
### Using Swift OpenAPI Generator for code generation
The generated code depends on types from this library. Check out the adoption guides in the [Swift OpenAPI Generator documentation][1] to see how the packages fit together.
### Implementing transports and middlewares
Swift OpenAPI Generator generates client and server code that is designed to be used with pluggable transports and middlewares.
Implement a new transport or middleware by providing a type that adopts one of the protocols from the runtime library:
* [`ClientTransport`](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation/openapiruntime/clienttransport)
* [`ClientMiddleware`](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation/openapiruntime/clientmiddleware)
* [`ServerTransport`](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation/openapiruntime/servertransport)
* [`ServerMiddleware`](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation/openapiruntime/servermiddleware)You can also publish your transport or middleware as a Swift package to allow others to use it with their generated code.
## Documentation
To learn more, check out the full [documentation][2].
[0]: https://github.com/apple/swift-openapi-generator
[1]: https://swiftpackageindex.com/apple/swift-openapi-generator/documentation
[2]: https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation