|
1 | 1 | # Swift OpenAPI Generator Runtime
|
2 | 2 |
|
3 |
| -This library provides common abstractions and helper functions used by all |
4 |
| -client and server code generated by [Swift OpenAPI Generator][0]. |
| 3 | +This library provides common abstractions and helper functions used by the client and server code generated by [Swift OpenAPI Generator][0]. |
5 | 4 |
|
6 |
| -To get started, check out the [documentation][1]. |
| 5 | +## Overview |
| 6 | + |
| 7 | +It contains: |
| 8 | +- Common types used in the code generated by the `swift-openapi-generator` package plugin. |
| 9 | +- Protocol definitions for pluggable layers, including `ClientTransport`, `ServerTransport`, and middleware. |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +Add the package dependency in your `Package.swift`: |
| 14 | + |
| 15 | +```swift |
| 16 | +.package(url: "https://github.com/apple/swift-openapi-runtime", from: "0.1.0"), |
| 17 | +``` |
| 18 | + |
| 19 | +and in your target, add `OpenAPIRuntime` to your dependencies: |
| 20 | + |
| 21 | +```swift |
| 22 | +.target(name: "MyTarget", dependencies: [ |
| 23 | + .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"), |
| 24 | +], |
| 25 | +``` |
| 26 | + |
| 27 | +The next step depends on your use case. |
| 28 | + |
| 29 | +### Using Swift OpenAPI Generator for code generation |
| 30 | + |
| 31 | +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. |
| 32 | + |
| 33 | +### Implementing transports and middlewares |
| 34 | + |
| 35 | +Swift OpenAPI Generator generates client and server code that is designed to be used with pluggable transports and middlewares. |
| 36 | + |
| 37 | +Implement a new transport or middleware by providing a type that adopts one of the protocols from the runtime library: |
| 38 | + |
| 39 | +* `ClientTransport` |
| 40 | +* `ClientMiddleware` |
| 41 | +* `ServerTransport` |
| 42 | +* `ServerMiddleware` |
| 43 | + |
| 44 | +You can also publish your transport or middleware as a Swift package to allow others to use it with their generated code. |
| 45 | + |
| 46 | +## Documentation |
| 47 | + |
| 48 | +To learn more, check out the full [documentation][2]. |
7 | 49 |
|
8 | 50 | [0]: https://github.com/apple/swift-openapi-generator
|
9 | 51 | [1]: https://swiftpackageindex.com/apple/swift-openapi-generator/documentation
|
| 52 | +[2]: https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation |
0 commit comments