Skip to content

Commit bc1023f

Browse files
authored
[Docs] Prep 1.0.0 (#89)
### Motivation Prep docs for 1.0. ### Modifications See above. ### Result Ready to tag 1.0. ### Test Plan Manual inspection.
1 parent 160ff92 commit bc1023f

File tree

5 files changed

+34
-65
lines changed

5 files changed

+34
-65
lines changed

README.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Swift OpenAPI Generator Runtime
22

33
[![](https://img.shields.io/badge/docc-read_documentation-blue)](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation)
4+
[![](https://img.shields.io/github/v/release/apple/swift-openapi-runtime)](https://github.com/apple/swift-openapi-runtime/releases)
45
[![](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)
56
[![](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)
67

@@ -10,27 +11,26 @@ This library provides common abstractions and helper functions used by the clien
1011

1112
It contains:
1213
- Common types used in the code generated by the `swift-openapi-generator` package plugin.
13-
- Protocol definitions for pluggable layers, including `ClientTransport`, `ServerTransport`, and middleware.
14+
- 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).
15+
16+
Many of the HTTP currency types used are defined in the [Swift HTTP Types](https://github.com/apple/swift-http-types) library.
17+
18+
> 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.
1419
1520
## Usage
1621

1722
Add the package dependency in your `Package.swift`:
1823

1924
```swift
20-
.package(
21-
url: "https://github.com/apple/swift-openapi-runtime",
22-
exact: "1.0.0-alpha.1"
23-
),
25+
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
2426
```
2527

26-
Note that this repository does not have a 1.0 tag yet, so the API is not stable.
27-
2828
Next, in your target, add `OpenAPIRuntime` to your dependencies:
2929

3030
```swift
3131
.target(name: "MyTarget", dependencies: [
3232
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
33-
],
33+
]),
3434
```
3535

3636
The next step depends on your use case.
@@ -45,17 +45,13 @@ Swift OpenAPI Generator generates client and server code that is designed to be
4545

4646
Implement a new transport or middleware by providing a type that adopts one of the protocols from the runtime library:
4747

48-
* `ClientTransport`
49-
* `ClientMiddleware`
50-
* `ServerTransport`
51-
* `ServerMiddleware`
48+
* [`ClientTransport`](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation/openapiruntime/clienttransport)
49+
* [`ClientMiddleware`](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation/openapiruntime/clientmiddleware)
50+
* [`ServerTransport`](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation/openapiruntime/servertransport)
51+
* [`ServerMiddleware`](https://swiftpackageindex.com/apple/swift-openapi-runtime/documentation/openapiruntime/servermiddleware)
5252

5353
You can also publish your transport or middleware as a Swift package to allow others to use it with their generated code.
5454

55-
## Reporting issues
56-
57-
Please report any issues related to this library in the [swift-openapi-generator](https://github.com/apple/swift-openapi-generator/issues) repository.
58-
5955
## Documentation
6056

6157
To learn more, check out the full [documentation][2].

Sources/OpenAPIRuntime/Base/Base64EncodedData.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import Foundation
1616

17-
/// Provides a route to encode or decode base64-encoded data
17+
/// A type for converting data as a base64 string.
1818
///
1919
/// This type holds raw, unencoded, data as a slice of bytes. It can be used to encode that
2020
/// data to a provided `Encoder` as base64-encoded data or to decode from base64 encoding when

Sources/OpenAPIRuntime/Documentation.docc/Documentation.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,26 @@ This library provides common abstractions and helper functions used by the clien
88

99
It contains:
1010
- 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.
11+
- Protocol definitions for pluggable layers, including ``ClientTransport``, ``ServerTransport``, ``ClientMiddleware``, and ``ServerMiddleware``.
1212

1313
Many of the HTTP currency types used are defined in the [Swift HTTP Types](https://github.com/apple/swift-http-types) library.
1414

15+
> 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.
16+
1517
### Usage
1618

1719
Add the package dependency in your `Package.swift`:
1820

1921
```swift
20-
.package(
21-
url: "https://github.com/apple/swift-openapi-runtime",
22-
exact: "1.0.0-alpha.1"
23-
),
22+
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
2423
```
2524

26-
Note that this repository does not have a 1.0 tag yet, so the API is not stable.
27-
2825
Next, in your target, add `OpenAPIRuntime` to your dependencies:
2926

3027
```swift
3128
.target(name: "MyTarget", dependencies: [
3229
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
33-
],
30+
]),
3431
```
3532

3633
The next step depends on your use case.
@@ -52,19 +49,15 @@ Implement a new transport or middleware by providing a type that adopts one of t
5249

5350
You can also publish your transport or middleware as a Swift package to allow others to use it with their generated code.
5451

55-
### Reporting issues
56-
57-
Please report any issues related to this library in the [swift-openapi-generator](https://github.com/apple/swift-openapi-generator/issues) repository.
58-
5952
## Topics
6053

6154
### Essentials
6255
- ``ClientTransport``
6356
- ``ServerTransport``
64-
65-
### Customization
6657
- ``ClientMiddleware``
6758
- ``ServerMiddleware``
59+
60+
### Customization
6861
- ``Configuration``
6962
- ``DateTranscoder``
7063
- ``ISO8601DateTranscoder``

Sources/OpenAPIRuntime/Interface/ClientTransport.swift

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,19 @@ import struct Foundation.URL
4141
///
4242
/// let transport = URLSessionTransport()
4343
///
44-
/// Create the base URL of the server to call using your client. If the server
45-
/// URL was defined in the OpenAPI document, you find a generated method for it
46-
/// on the `Servers` type, for example:
47-
///
48-
/// let serverURL = try Servers.server1()
49-
///
5044
/// Instantiate the `Client` type generated by the Swift OpenAPI Generator for
5145
/// your provided OpenAPI document. For example:
5246
///
5347
/// let client = Client(
54-
/// serverURL: serverURL,
48+
/// serverURL: URL(string: "https://example.com")!,
5549
/// transport: transport
5650
/// )
5751
///
5852
/// Use the client to make HTTP calls defined in your OpenAPI document. For
5953
/// example, if the OpenAPI document contains an HTTP operation with
6054
/// the identifier `checkHealth`, call it from Swift with:
6155
///
62-
/// let response = try await client.checkHealth(.init())
63-
/// switch response {
64-
/// case .ok(let okPayload):
65-
/// // ...
66-
///
67-
/// // Handle any HTTP status code not documented in
68-
/// // your OpenAPI document.
69-
/// case .undocumented(let statusCode, _):
70-
/// // ...
71-
/// }
56+
/// let response = try await client.checkHealth()
7257
///
7358
/// The generated operation method takes an `Input` type unique to
7459
/// the operation, and returns an `Output` type unique to the operation.
@@ -107,16 +92,13 @@ import struct Foundation.URL
10792
/// Then in your test code, instantiate and provide the test transport to your
10893
/// generated client instead:
10994
///
110-
/// let transport = TestTransport()
95+
/// var transport = TestTransport()
11196
/// transport.isHealthy = true // for HTTP status code 200 (success)
112-
/// transport.isHealthy = false // for HTTP status code 500 (failure)
113-
/// let serverURL = try Servers.server1()
11497
/// let client = Client(
115-
/// serverURL: serverURL,
98+
/// serverURL: URL(string: "https://example.com")!,
11699
/// transport: transport
117100
/// )
118-
/// let response = try await client.checkHealth(.init())
119-
/// // ...
101+
/// let response = try await client.checkHealth()
120102
///
121103
/// Implementing a test client transport is just one way to help test your
122104
/// code that integrates with a generated client. Another is to implement
@@ -172,7 +154,7 @@ public protocol ClientTransport: Sendable {
172154
/// the middleware to the initializer of the generated `Client` type:
173155
///
174156
/// let client = Client(
175-
/// serverURL: serverURL,
157+
/// serverURL: URL(string: "https://example.com")!,
176158
/// transport: transport,
177159
/// middlewares: [
178160
/// loggingMiddleware,
@@ -181,8 +163,7 @@ public protocol ClientTransport: Sendable {
181163
///
182164
/// Then make a call to one of the generated client methods:
183165
///
184-
/// let response = try await client.checkHealth(.init())
185-
/// // ...
166+
/// let response = try await client.checkHealth()
186167
///
187168
/// As part of the invocation of `checkHealth`, the client first invokes
188169
/// the middlewares in the order you provided them, and then passes the request

Sources/OpenAPIRuntime/Interface/ServerTransport.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,19 @@ import HTTPTypes
7171
///
7272
/// Create the URL where the server will run. The path of the URL is extracted
7373
/// by the transport to create a common prefix (such as `/api/v1`) that might
74-
/// be expected by the clients. If the server URL is defined in the OpenAPI
75-
/// document, find the generated method for it on the `Servers` type,
76-
/// for example:
77-
///
78-
/// let serverURL = try Servers.server1()
74+
/// be expected by the clients.
7975
///
8076
/// Register the generated request handlers by calling the method generated
8177
/// on the `APIProtocol` protocol:
8278
///
83-
/// try handler.registerHandlers(on: transport, serverURL: serverURL)
79+
/// try handler.registerHandlers(
80+
/// on: transport,
81+
/// serverURL: URL(string: "/api/v1")!
82+
/// )
8483
///
8584
/// Start the server by following the documentation of your chosen transport:
8685
///
87-
/// try app.run()
86+
/// try await app.execute()
8887
///
8988
/// ### Implement a custom server transport
9089
///
@@ -161,7 +160,7 @@ public protocol ServerTransport {
161160
///
162161
/// try handler.registerHandlers(
163162
/// on: transport,
164-
/// serverURL: serverURL,
163+
/// serverURL: URL(string: "/api/v1")!,
165164
/// middlewares: [
166165
/// loggingMiddleware,
167166
/// ]

0 commit comments

Comments
 (0)