Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Examples/auth-server-middleware-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/swift-server/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/vapor", from: "4.89.0"),
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Examples/auth-server-middleware-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ with a new target, `AuthenticationServerMiddleware`, which is then used when reg

NOTE: This example shows just one way of varifying authentication information in a middleware and is purely for illustrative purposes.

The tool uses the [Vapor](https://github.com/vapor/vapor) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Vapor Transport](https://github.com/swift-server/swift-openapi-vapor).
The tool uses the [Vapor](https://github.com/vapor/vapor) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Vapor Transport](https://github.com/vapor/swift-openapi-vapor).

The CLI starts the server on `http://localhost:8080` and can be invoked by running the `AuthenticationClientMiddleware` example client or on the command line using:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.5.0"),
.package(url: "https://github.com/swift-server/swift-openapi-hummingbird.git", from: "2.0.1"),
.package(url: "https://github.com/hummingbird-project/swift-openapi-hummingbird.git", from: "2.0.1"),
],
targets: [
.executableTarget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ An example project using [Swift OpenAPI Generator](https://github.com/apple/swif

A server that uses generated server stubs to show how to work with bidirectional event streams.

The tool uses the [Hummingbird](https://github.com/hummingbird-project/hummingbird) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Hummingbird](https://github.com/swift-server/swift-openapi-hummingbird).
The tool uses the [Hummingbird](https://github.com/hummingbird-project/hummingbird) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Hummingbird](https://github.com/hummingbird-project/swift-openapi-hummingbird).

The CLI starts the server on `http://localhost:8080` and can be invoked by running `bidirectional-event-streams-client-example`.

Expand Down
2 changes: 1 addition & 1 deletion Examples/event-streams-server-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/swift-server/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/vapor", from: "4.89.0"),
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Examples/event-streams-server-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ An example project using [Swift OpenAPI Generator](https://github.com/apple/swif

A server that uses generated server stubs to show how to work with event streams, such as JSON Lines, JSON Sequence, and Server-sent Events.

The tool uses the [Vapor](https://github.com/vapor/vapor) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Vapor Transport](https://github.com/swift-server/swift-openapi-vapor).
The tool uses the [Vapor](https://github.com/vapor/vapor) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Vapor Transport](https://github.com/vapor/swift-openapi-vapor).

The CLI starts the server on `http://localhost:8080` and can be invoked by running `event-streams-client-example` or on the command line using:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/swift-server/swift-openapi-hummingbird", from: "2.0.1"),
.package(url: "https://github.com/hummingbird-project/swift-openapi-hummingbird", from: "2.0.1"),
.package(url: "https://github.com/hummingbird-project/hummingbird", from: "2.5.0"),
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Examples/hello-world-hummingbird-server-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ An example project using [Swift OpenAPI Generator](https://github.com/apple/swif

A "hello world" server that uses generated server stubs to handle requests as the Greeting Service.

The tool uses the [Hummingbird](https://github.com/hummingbird-project/hummingbird) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Hummingbird Transport](https://github.com/swift-server/swift-openapi-hummingbird).
The tool uses the [Hummingbird](https://github.com/hummingbird-project/hummingbird) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Hummingbird Transport](https://github.com/hummingbird-project/swift-openapi-hummingbird).

The CLI starts the server on `http://localhost:8080` and can be invoked by running any of the Hello World example clients or on the command line using:

Expand Down
2 changes: 1 addition & 1 deletion Examples/hello-world-vapor-server-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/swift-server/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/vapor", from: "4.89.0"),
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Examples/hello-world-vapor-server-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ An example project using [Swift OpenAPI Generator](https://github.com/apple/swif

A "hello world" server that uses generated server stubs to handle requests as the Greeting Service.

The tool uses the [Vapor](https://github.com/vapor/vapor) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Vapor Transport](https://github.com/swift-server/swift-openapi-vapor).
The tool uses the [Vapor](https://github.com/vapor/vapor) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Vapor Transport](https://github.com/vapor/swift-openapi-vapor).

The CLI starts the server on `http://localhost:8080` and can be invoked by running any of the Hello World example clients or on the command line using:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ extension LoggingMiddleware: ServerMiddleware {
body: OpenAPIRuntime.HTTPBody?,
metadata: OpenAPIRuntime.ServerRequestMetadata,
operationID: String,
next: @Sendable (HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata)
next:
@Sendable (HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata)
async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?)
) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) {
let (requestBodyToLog, requestBodyForNext) = try await bodyLoggingPolicy.process(body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ extension LoggingMiddleware: ServerMiddleware {
body: OpenAPIRuntime.HTTPBody?,
metadata: OpenAPIRuntime.ServerRequestMetadata,
operationID: String,
next: @Sendable (HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata)
next:
@Sendable (HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata)
async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?)
) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) {
let (requestBodyToLog, requestBodyForNext) = try await bodyLoggingPolicy.process(body)
Expand Down
2 changes: 1 addition & 1 deletion Examples/metrics-middleware-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/swift-server/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/vapor", from: "4.89.0"),
.package(url: "https://github.com/apple/swift-metrics", from: "2.4.1"),
.package(url: "https://github.com/swift-server/swift-prometheus", from: "2.0.0"),
Expand Down
2 changes: 1 addition & 1 deletion Examples/postgres-database-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/swift-server/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/vapor", from: "4.89.0"),
.package(url: "https://github.com/vapor/postgres-nio", from: "1.19.1"),
],
Expand Down
2 changes: 1 addition & 1 deletion Examples/shared-types-client-server-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
.package(url: "https://github.com/swift-server/swift-openapi-hummingbird", from: "2.0.0"),
.package(url: "https://github.com/hummingbird-project/swift-openapi-hummingbird", from: "2.0.0"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion Examples/streaming-chatgpt-proxy/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.2"),
.package(url: "https://github.com/swift-server/swift-openapi-vapor", from: "1.0.1"),
.package(url: "https://github.com/vapor/swift-openapi-vapor", from: "1.0.1"),
.package(url: "https://github.com/swift-server/swift-openapi-async-http-client", from: "1.1.0"),
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Examples/swagger-ui-endpoint-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/swift-server/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/vapor", from: "4.108.0"),
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Examples/swagger-ui-endpoint-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The OpenAPI document also contains the following server definition, which allows
description: This server.
```

The tool uses the [Vapor](https://github.com/vapor/vapor) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Vapor Transport](https://github.com/swift-server/swift-openapi-vapor).
The tool uses the [Vapor](https://github.com/vapor/vapor) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Vapor Transport](https://github.com/vapor/swift-openapi-vapor).

The CLI starts the server on `http://localhost:8080` and you can go to `http://localhost:8080/openapi.yaml` to see the raw OpenAPI document, and to `http://localhost:8080/openapi` to see the rendered documentation.

Expand Down
2 changes: 1 addition & 1 deletion Examples/tracing-middleware-example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/swift-server/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/vapor", from: "4.108.0"),
.package(url: "https://github.com/apple/swift-distributed-tracing", from: "1.0.1"),
.package(url: "https://github.com/apple/swift-distributed-tracing-extras", exact: "1.0.0-beta.1"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/swift-server/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/swift-openapi-vapor", from: "1.0.0"),
.package(url: "https://github.com/vapor/vapor", from: "4.89.0"),
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Examples/various-content-types-server-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ An example project using [Swift OpenAPI Generator](https://github.com/apple/swif

A server that uses generated server stubs to show how to work with various HTTP content types.

The tool uses the [Vapor](https://github.com/vapor/vapor) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Vapor Transport](https://github.com/swift-server/swift-openapi-vapor).
The tool uses the [Vapor](https://github.com/vapor/vapor) server framework to handle HTTP requests, wrapped in the [Swift OpenAPI Vapor Transport](https://github.com/vapor/swift-openapi-vapor).

The CLI starts the server on `http://localhost:8080` and can be invoked by running `various-content-types-client-example` or on the command line using:

Expand Down
6 changes: 3 additions & 3 deletions IntegrationTest/Sources/MockTransportServer/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ actor SimpleAPIImpl: APIProtocol {
}

class MockServerTransport: ServerTransport {
typealias Handler = @Sendable (
HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata
) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?)
typealias Handler =
@Sendable (HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, OpenAPIRuntime.ServerRequestMetadata) async throws
-> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?)

func register(_ handler: @escaping Handler, method: HTTPTypes.HTTPRequest.Method, path: String) throws {
// noop.
Expand Down
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ The Swift OpenAPI Generator project is split across multiple repositories to ena
| [apple/swift-openapi-runtime][repo-runtime] | Runtime library used by the generated code |
| [apple/swift-openapi-urlsession][repo-urlsession] | `ClientTransport` using [URLSession][urlsession] |
| [swift-server/swift-openapi-async-http-client][repo-ahc] | `ClientTransport` using [AsyncHTTPClient][ahc] |
| [swift-server/swift-openapi-vapor][repo-vapor] | `ServerTransport` using [Vapor][vapor] |
| [swift-server/swift-openapi-hummingbird][repo-hummingbird] | `ServerTransport` using [Hummingbird][hummingbird] |
| [vapor/swift-openapi-vapor][repo-vapor] | `ServerTransport` using [Vapor][vapor] |
| [hummingbird-project/swift-openapi-hummingbird][repo-hummingbird] | `ServerTransport` using [Hummingbird][hummingbird] |
| [swift-server/swift-openapi-lambda][repo-lambda] | `ServerTransport` using [AWS Lambda][lambda] |

## Requirements and supported features

| Generator versions | Supported OpenAPI versions | Minimum Swift version |
| ------------------ | -------------------------- | --------------------- |
| `1.0.0` ... `main` | 3.0, 3.1 | 5.9 |
| Generator versions | Supported OpenAPI versions |
| ------------------ | -------------------------- |
| `1.0.0` ... `main` | 3.0, 3.1 |

See also [Supported OpenAPI features][supported-openapi-features].

Expand All @@ -109,9 +109,6 @@ platforms, listed below.
| Generator plugin and CLI | ✅ 10.15+ | ✅ | ✖️ | ✖️ | ✖️ | ✖️ |
| Generated code and runtime library | ✅ 10.15+ | ✅ | ✅ 13+ | ✅ 13+ | ✅ 6+ | ✅ 1+ |

> [!NOTE]
> When using Visual Studio Code or other editors that rely on [SourceKit-LSP](https://github.com/swiftlang/sourcekit-lsp), the editor may not correctly recognize generated code within the same module. As a workaround, consider creating a separate target for code generation and then importing it into your main module. For more details, see the discussion in [swiftlang/sourcekit-lsp#665](https://github.com/swiftlang/sourcekit-lsp/issues/665#issuecomment-2093169169).

## Documentation and example projects

To get started, check out the [documentation][docs-generator], which contains
Expand All @@ -134,9 +131,9 @@ Generator](https://developer.apple.com/wwdc23/10171) from WWDC23.
[urlsession]: https://developer.apple.com/documentation/foundation/urlsession
[repo-ahc]: https://github.com/swift-server/swift-openapi-async-http-client
[ahc]: https://github.com/swift-server/async-http-client
[repo-vapor]: https://github.com/swift-server/swift-openapi-vapor
[repo-vapor]: https://github.com/vapor/swift-openapi-vapor
[vapor]: https://github.com/vapor/vapor
[repo-hummingbird]: https://github.com/swift-server/swift-openapi-hummingbird
[repo-hummingbird]: https://github.com/hummingbird-project/swift-openapi-hummingbird
[hummingbird]: https://github.com/hummingbird-project/hummingbird
[repo-lambda]: https://github.com/swift-server/swift-openapi-lambda
[lambda]: https://docs.aws.amazon.com/lambda/latest/dg/welcome.html
Expand Down
5 changes: 2 additions & 3 deletions Sources/PetstoreConsumerTestCore/TestClientTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ import HTTPTypes
public struct TestClientTransport: ClientTransport {

/// A typealias representing a call handler closure for processing client requests.
public typealias CallHandler = @Sendable (HTTPRequest, HTTPBody?, URL, String) async throws -> (
HTTPResponse, HTTPBody?
)
public typealias CallHandler =
@Sendable (HTTPRequest, HTTPBody?, URL, String) async throws -> (HTTPResponse, HTTPBody?)

/// The call handler responsible for processing client requests.
public let callHandler: CallHandler
Expand Down
12 changes: 6 additions & 6 deletions Sources/PetstoreConsumerTestCore/TestServerTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ public final class TestServerTransport: ServerTransport {
}

/// A typealias representing a handler closure for processing server requests.
public typealias Handler = @Sendable (HTTPRequest, HTTPBody?, ServerRequestMetadata) async throws -> (
HTTPResponse, HTTPBody?
)
public typealias Handler =
@Sendable (HTTPRequest, HTTPBody?, ServerRequestMetadata) async throws -> (HTTPResponse, HTTPBody?)

/// Represents an operation with its inputs and associated handler.
public struct Operation {
Expand Down Expand Up @@ -86,9 +85,10 @@ public final class TestServerTransport: ServerTransport {
/// - path: The path components of the operation.
/// - Throws: An error if there's an issue registering the operation.
public func register(
_ handler: @Sendable @escaping (HTTPRequest, HTTPBody?, ServerRequestMetadata) async throws -> (
HTTPResponse, HTTPBody?
),
_ handler:
@Sendable @escaping (HTTPRequest, HTTPBody?, ServerRequestMetadata) async throws -> (
HTTPResponse, HTTPBody?
),
method: HTTPRequest.Method,
path: String
) throws { registered.append(Operation(inputs: .init(method: method, path: path), closure: handler)) }
Expand Down
Loading