Skip to content

Commit 2b329b7

Browse files
authored
Expand README with more info from the docc bundle (#3)
Expand README with more info from the docc bundle ## Summary Copied a subset of the information on the landing page of the docc bundle into the README. ## Test Plan Previewed locally, looks good. Reviewed by: simonjbeaumont Builds: ✔︎ pull request validation (5.8) - Build finished. ✔︎ pull request validation (5.9) - Build finished. ✔︎ pull request validation (nightly) - Build finished. ✔︎ pull request validation (soundness) - Build finished. #3
1 parent 9c5b6f6 commit 2b329b7

File tree

2 files changed

+83
-7
lines changed

2 files changed

+83
-7
lines changed

README.md

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,52 @@
11
# Swift OpenAPI Generator Runtime
22

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].
54

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].
749

850
[0]: https://github.com/apple/swift-openapi-generator
951
[1]: https://swiftpackageindex.com/apple/swift-openapi-generator/documentation
52+
[2]: https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation

Sources/OpenAPIRuntime/Documentation.docc/Documentation.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,46 @@ Use and extend your client and server code generated by Swift OpenAPI Generato
44

55
## Overview
66

7+
This library provides common abstractions and helper functions used by the client and server code generated by [Swift OpenAPI Generator][0].
78

8-
This library provides common abstractions and helper functions used by all client and server code generated by [Swift OpenAPI Generator][0].
9+
It contains:
10+
- Common types used in the code generated by the `swift-openapi-generator` package plugin.
11+
- Protocol definitions for pluggable layers, including ``ClientTransport``, ``ServerTransport``, and middleware.
912

10-
### Supported Use Cases
13+
### Usage
1114

12-
1. Use the types from this library to instantiate your generated client and server code. To learn more, review the adoption guides in the [Swift OpenAPI Generator documentation][1].
13-
2. Implement a custom transport or middleware to extend your generated client and server. For client code, check out ``ClientTransport`` and ``ClientMiddleware``. For server code, check out ``ServerTransport`` and ``ServerMiddleware``.
15+
Add the package dependency in your `Package.swift`:
16+
17+
```swift
18+
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "0.1.0"),
19+
```
20+
21+
and in your target, add `OpenAPIRuntime` to your dependencies:
22+
23+
```swift
24+
.target(name: "MyTarget", dependencies: [
25+
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
26+
],
27+
```
28+
29+
The next step depends on your use case.
30+
31+
#### Using Swift OpenAPI Generator for code generation
32+
33+
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.
34+
35+
#### Implementing transports and middlewares
36+
37+
Swift OpenAPI Generator generates client and server code that is designed to be used with pluggable transports and middlewares.
38+
39+
Implement a new transport or middleware by providing a type that adopts one of the protocols from the runtime library:
40+
41+
* ``ClientTransport``
42+
* ``ClientMiddleware``
43+
* ``ServerTransport``
44+
* ``ServerMiddleware``
45+
46+
You can also publish your transport or middleware as a Swift package to allow others to use it with their generated code.
1447

1548
## Topics
1649

0 commit comments

Comments
 (0)