From dca7251ea7a0d1b6ed2c8aff2d1772f02a8c7a00 Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Thu, 19 Dec 2024 15:54:23 +0100 Subject: [PATCH] Update Examples and IntegrationTest to use idiomatic naming --- .../project.pbxproj | 4 +- .../HelloWorldiOSClientApp/ContentView.swift | 2 +- .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../HelloWorldVaporServer.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../BidirectionalEventStreamsClient.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../Package.swift | 10 ++-- .../BidirectionalEventStreamsServer.swift | 6 +- .../GreetingStream.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../command-line-client-example/Package.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../CuratedLibraryClientTests.swift | 2 +- .../Package.swift | 4 +- .../EventStreamsClient.swift | 12 ++-- .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../EventStreamsServer.swift | 22 +++---- .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../Package.swift | 10 ++-- .../HelloWorldHummingbirdServer.swift | 10 ++-- .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../HelloWorldVaporServer.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../Makefile | 2 +- .../Package.swift | 2 +- .../Generated/Client.swift | 6 +- .../Generated/Types.swift | 32 +++++----- .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../GeneratedSources/Client.swift | 6 +- .../GeneratedSources/Types.swift | 32 +++++----- .../openapi-generator-config.yaml | 1 + .../metrics-middleware-example/Package.swift | 6 +- .../HelloWorldVaporServer.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../postgres-database-example/Package.swift | 4 +- .../PostgresDatabaseServer.swift | 8 +-- .../openapi-generator-config.yaml | 1 + .../retrying-middleware-example/Package.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../Package.swift | 8 +-- .../Client/openapi-generator-config.yaml | 1 + .../Server/HelloWorldHummingbirdServer.swift | 10 ++-- .../Server/openapi-generator-config.yaml | 1 + .../Types/openapi-generator-config.yaml | 1 + .../swagger-ui-endpoint-example/Package.swift | 8 +-- .../SwaggerUIEndpointsServer.swift | 4 +- .../openapi-generator-config.yaml | 1 + .../tracing-middleware-example/Package.swift | 12 ++-- .../HelloWorldVaporServer.swift | 59 +++++++++++++------ .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../ContentTypesClient.swift | 6 +- .../openapi-generator-config.yaml | 1 + .../Package.swift | 4 +- .../ContentTypesServer.swift | 54 ++++++++--------- .../openapi-generator-config.yaml | 1 + .../ContentTypesServerTests.swift | 2 +- IntegrationTest/Package.swift | 4 +- .../Client/openapi-generator-config.yaml | 1 + .../Sources/MockTransportServer/Server.swift | 2 +- .../Server/openapi-generator-config.yaml | 1 + .../Types/openapi-generator-config.yaml | 1 + 80 files changed, 256 insertions(+), 203 deletions(-) diff --git a/Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp.xcodeproj/project.pbxproj b/Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp.xcodeproj/project.pbxproj index 50fa8ce7..7ec7c9e8 100644 --- a/Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp.xcodeproj/project.pbxproj +++ b/Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp.xcodeproj/project.pbxproj @@ -609,7 +609,7 @@ repositoryURL = "https://github.com/apple/swift-openapi-generator.git"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 1.0.0; + minimumVersion = 1.6.0; }; }; 3A133D0E2B1F2A600008DD5E /* XCRemoteSwiftPackageReference "swift-openapi-runtime" */ = { @@ -617,7 +617,7 @@ repositoryURL = "https://github.com/apple/swift-openapi-runtime.git"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 1.0.0; + minimumVersion = 1.7.0; }; }; 3A133D112B1F2A730008DD5E /* XCRemoteSwiftPackageReference "swift-openapi-urlsession" */ = { diff --git a/Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp/ContentView.swift b/Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp/ContentView.swift index da02deb7..39e25cc4 100644 --- a/Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp/ContentView.swift +++ b/Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp/ContentView.swift @@ -60,7 +60,7 @@ struct ContentView: View { // A mock client used in previews and tests to avoid making live network calls. struct MockClient: APIProtocol { - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { let name = input.query.name ?? "Stranger" return .ok(.init(body: .json(.init(message: "(Mock) Hello, \(name)!")))) } diff --git a/Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp/openapi-generator-config.yaml b/Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp/openapi-generator-config.yaml +++ b/Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/auth-client-middleware-example/Package.swift b/Examples/auth-client-middleware-example/Package.swift index 106d71a7..37c16eeb 100644 --- a/Examples/auth-client-middleware-example/Package.swift +++ b/Examples/auth-client-middleware-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "auth-client-middleware-example", platforms: [.macOS(.v11), .iOS(.v14), .tvOS(.v14), .watchOS(.v7), .visionOS(.v1)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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/apple/swift-http-types", from: "1.0.2"), ], diff --git a/Examples/auth-client-middleware-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml b/Examples/auth-client-middleware-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/auth-client-middleware-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml +++ b/Examples/auth-client-middleware-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/auth-server-middleware-example/Package.swift b/Examples/auth-server-middleware-example/Package.swift index 82221feb..f5994684 100644 --- a/Examples/auth-server-middleware-example/Package.swift +++ b/Examples/auth-server-middleware-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "auth-server-middleware-example", platforms: [.macOS(.v10_15)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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/vapor", from: "4.89.0"), ], diff --git a/Examples/auth-server-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift b/Examples/auth-server-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift index 33566f73..526f3ba6 100644 --- a/Examples/auth-server-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift +++ b/Examples/auth-server-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift @@ -17,7 +17,7 @@ import Vapor import AuthenticationServerMiddleware struct Handler: APIProtocol { - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { // Extract the authenticated user, if present. // If unauthenticated, return the 401 HTTP status code. // Note that the 401 is defined in the OpenAPI document, allowing the client @@ -32,7 +32,7 @@ struct Handler: APIProtocol { @main struct HelloWorldVaporServer { static func main() async throws { - let app = Vapor.Application() + let app = try await Vapor.Application.make() let transport = VaporTransport(routesBuilder: app) let handler = Handler() try handler.registerHandlers( diff --git a/Examples/auth-server-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml b/Examples/auth-server-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml index f68d9c85..99d15462 100644 --- a/Examples/auth-server-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml +++ b/Examples/auth-server-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - server accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/bidirectional-event-streams-client-example/Package.swift b/Examples/bidirectional-event-streams-client-example/Package.swift index 570e4f16..8e16ea85 100644 --- a/Examples/bidirectional-event-streams-client-example/Package.swift +++ b/Examples/bidirectional-event-streams-client-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "bidirectional-event-streams-client-example", platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.2.0"), + .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-async-http-client", from: "1.0.0"), ], targets: [ diff --git a/Examples/bidirectional-event-streams-client-example/Sources/BidirectionalEventStreamsClient/BidirectionalEventStreamsClient.swift b/Examples/bidirectional-event-streams-client-example/Sources/BidirectionalEventStreamsClient/BidirectionalEventStreamsClient.swift index b5b82b26..dc2e83d8 100644 --- a/Examples/bidirectional-event-streams-client-example/Sources/BidirectionalEventStreamsClient/BidirectionalEventStreamsClient.swift +++ b/Examples/bidirectional-event-streams-client-example/Sources/BidirectionalEventStreamsClient/BidirectionalEventStreamsClient.swift @@ -27,11 +27,11 @@ import Foundation let (stream, continuation) = AsyncStream.makeStream() /// To keep it simple, using JSON Lines, as it most straightforward and easy way to have streams. /// For SSE and JSON Sequences cases please check `event-streams-client-example`. - let requestBody: Operations.getGreetingsStream.Input.Body = .application_jsonl( + let requestBody: Operations.GetGreetingsStream.Input.Body = .applicationJsonl( .init(stream.asEncodedJSONLines(), length: .unknown, iterationBehavior: .single) ) let response = try await client.getGreetingsStream(query: .init(name: "Example"), body: requestBody) - let greetingStream = try response.ok.body.application_jsonl.asDecodedJSONLines( + let greetingStream = try response.ok.body.applicationJsonl.asDecodedJSONLines( of: Components.Schemas.Greeting.self ) try await withThrowingTaskGroup(of: Void.self) { group in diff --git a/Examples/bidirectional-event-streams-client-example/Sources/BidirectionalEventStreamsClient/openapi-generator-config.yaml b/Examples/bidirectional-event-streams-client-example/Sources/BidirectionalEventStreamsClient/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/bidirectional-event-streams-client-example/Sources/BidirectionalEventStreamsClient/openapi-generator-config.yaml +++ b/Examples/bidirectional-event-streams-client-example/Sources/BidirectionalEventStreamsClient/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/bidirectional-event-streams-server-example/Package.swift b/Examples/bidirectional-event-streams-server-example/Package.swift index 5b079ae6..d7f9487d 100644 --- a/Examples/bidirectional-event-streams-server-example/Package.swift +++ b/Examples/bidirectional-event-streams-server-example/Package.swift @@ -16,12 +16,12 @@ import PackageDescription let package = Package( name: "bidirectional-event-streams-server-example", - platforms: [.macOS(.v10_15)], + platforms: [.macOS(.v14)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.2.0"), - .package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0-rc.1"), - .package(url: "https://github.com/swift-server/swift-openapi-hummingbird.git", from: "2.0.0-beta.4"), + .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"), ], targets: [ .executableTarget( diff --git a/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/BidirectionalEventStreamsServer.swift b/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/BidirectionalEventStreamsServer.swift index 01da6351..8433143b 100644 --- a/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/BidirectionalEventStreamsServer.swift +++ b/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/BidirectionalEventStreamsServer.swift @@ -18,13 +18,13 @@ import Foundation struct Handler: APIProtocol { private let storage: StreamStorage = .init() - func getGreetingsStream(_ input: Operations.getGreetingsStream.Input) async throws - -> Operations.getGreetingsStream.Output + func getGreetingsStream(_ input: Operations.GetGreetingsStream.Input) async throws + -> Operations.GetGreetingsStream.Output { let eventStream = await self.storage.makeStream(input: input) /// To keep it simple, using JSON Lines, as it most straightforward and easy way to have streams. /// For SSE and JSON Sequences cases please check `event-streams-server-example`. - let responseBody = Operations.getGreetingsStream.Output.Ok.Body.application_jsonl( + let responseBody = Operations.GetGreetingsStream.Output.Ok.Body.applicationJsonl( .init(eventStream.asEncodedJSONLines(), length: .unknown, iterationBehavior: .single) ) return .ok(.init(body: responseBody)) diff --git a/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/GreetingStream.swift b/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/GreetingStream.swift index 0e87bb13..88d115e7 100644 --- a/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/GreetingStream.swift +++ b/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/GreetingStream.swift @@ -28,7 +28,7 @@ actor StreamStorage: Sendable { task.cancel() print("Canceled stream \(id)") } - func makeStream(input: Operations.getGreetingsStream.Input) -> AsyncStream { + func makeStream(input: Operations.GetGreetingsStream.Input) -> AsyncStream { let name = input.query.name ?? "Stranger" let id = UUID().uuidString print("Creating stream \(id) for name: \(name)") @@ -44,7 +44,7 @@ actor StreamStorage: Sendable { } let inputStream = switch input.body { - case .application_jsonl(let body): body.asDecodedJSONLines(of: Components.Schemas.Greeting.self) + case .applicationJsonl(let body): body.asDecodedJSONLines(of: Components.Schemas.Greeting.self) } let task = Task { for try await message in inputStream { diff --git a/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/openapi-generator-config.yaml b/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/openapi-generator-config.yaml index f68d9c85..99d15462 100644 --- a/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/openapi-generator-config.yaml +++ b/Examples/bidirectional-event-streams-server-example/Sources/BidirectionalEventStreamsServer/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - server accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/command-line-client-example/Package.swift b/Examples/command-line-client-example/Package.swift index af977960..c22e0ed7 100644 --- a/Examples/command-line-client-example/Package.swift +++ b/Examples/command-line-client-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "command-line-client-example", platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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/apple/swift-argument-parser", from: "1.3.0"), ], diff --git a/Examples/command-line-client-example/Sources/CommandLineClient/openapi-generator-config.yaml b/Examples/command-line-client-example/Sources/CommandLineClient/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/command-line-client-example/Sources/CommandLineClient/openapi-generator-config.yaml +++ b/Examples/command-line-client-example/Sources/CommandLineClient/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/curated-client-library-example/Package.swift b/Examples/curated-client-library-example/Package.swift index ee27eb67..1b43e1cd 100644 --- a/Examples/curated-client-library-example/Package.swift +++ b/Examples/curated-client-library-example/Package.swift @@ -19,8 +19,8 @@ let package = Package( platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)], products: [.library(name: "CuratedLibraryClient", targets: ["CuratedLibraryClient"])], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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"), ], targets: [ diff --git a/Examples/curated-client-library-example/Sources/CuratedLibraryClient/openapi-generator-config.yaml b/Examples/curated-client-library-example/Sources/CuratedLibraryClient/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/curated-client-library-example/Sources/CuratedLibraryClient/openapi-generator-config.yaml +++ b/Examples/curated-client-library-example/Sources/CuratedLibraryClient/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/curated-client-library-example/Tests/CuratedLibraryClientTests/CuratedLibraryClientTests.swift b/Examples/curated-client-library-example/Tests/CuratedLibraryClientTests/CuratedLibraryClientTests.swift index cc696c42..6f8aebfb 100644 --- a/Examples/curated-client-library-example/Tests/CuratedLibraryClientTests/CuratedLibraryClientTests.swift +++ b/Examples/curated-client-library-example/Tests/CuratedLibraryClientTests/CuratedLibraryClientTests.swift @@ -49,7 +49,7 @@ struct TestClient: APIProtocol { var name: String? } - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { guard !shouldFail else { throw TestError(name: input.query.name) } let name = input.query.name ?? "Stranger" return .ok(.init(body: .json(.init(message: "(Test) Hello, \(name)!")))) diff --git a/Examples/event-streams-client-example/Package.swift b/Examples/event-streams-client-example/Package.swift index 5e72a919..4fd28af9 100644 --- a/Examples/event-streams-client-example/Package.swift +++ b/Examples/event-streams-client-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "event-streams-client-example", platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.2.0"), + .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"), ], targets: [ diff --git a/Examples/event-streams-client-example/Sources/EventStreamsClient/EventStreamsClient.swift b/Examples/event-streams-client-example/Sources/EventStreamsClient/EventStreamsClient.swift index 99082c57..e400b83f 100644 --- a/Examples/event-streams-client-example/Sources/EventStreamsClient/EventStreamsClient.swift +++ b/Examples/event-streams-client-example/Sources/EventStreamsClient/EventStreamsClient.swift @@ -22,9 +22,9 @@ import Foundation print("Fetching greetings using JSON Lines") let response = try await client.getGreetingsStream( query: .init(name: "Example", count: 3), - headers: .init(accept: [.init(contentType: .application_jsonl)]) + headers: .init(accept: [.init(contentType: .applicationJsonl)]) ) - let greetingStream = try response.ok.body.application_jsonl.asDecodedJSONLines( + let greetingStream = try response.ok.body.applicationJsonl.asDecodedJSONLines( of: Components.Schemas.Greeting.self ) for try await greeting in greetingStream { print("Got greeting: \(greeting.message)") } @@ -33,9 +33,9 @@ import Foundation print("Fetching greetings using JSON Sequence") let response = try await client.getGreetingsStream( query: .init(name: "Example", count: 3), - headers: .init(accept: [.init(contentType: .application_json_hyphen_seq)]) + headers: .init(accept: [.init(contentType: .applicationJsonSeq)]) ) - let greetingStream = try response.ok.body.application_json_hyphen_seq.asDecodedJSONSequence( + let greetingStream = try response.ok.body.applicationJsonSeq.asDecodedJSONSequence( of: Components.Schemas.Greeting.self ) for try await greeting in greetingStream { print("Got greeting: \(greeting.message)") } @@ -44,9 +44,9 @@ import Foundation print("Fetching greetings using Server-sent Events") let response = try await client.getGreetingsStream( query: .init(name: "Example", count: 3), - headers: .init(accept: [.init(contentType: .text_event_hyphen_stream)]) + headers: .init(accept: [.init(contentType: .textEventStream)]) ) - let greetingStream = try response.ok.body.text_event_hyphen_stream.asDecodedServerSentEventsWithJSONData( + let greetingStream = try response.ok.body.textEventStream.asDecodedServerSentEventsWithJSONData( of: Components.Schemas.Greeting.self ) for try await greeting in greetingStream { print("Got greeting: \(greeting.data?.message ?? "")") } diff --git a/Examples/event-streams-client-example/Sources/EventStreamsClient/openapi-generator-config.yaml b/Examples/event-streams-client-example/Sources/EventStreamsClient/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/event-streams-client-example/Sources/EventStreamsClient/openapi-generator-config.yaml +++ b/Examples/event-streams-client-example/Sources/EventStreamsClient/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/event-streams-server-example/Package.swift b/Examples/event-streams-server-example/Package.swift index cd13266b..f017fad9 100644 --- a/Examples/event-streams-server-example/Package.swift +++ b/Examples/event-streams-server-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "event-streams-server-example", platforms: [.macOS(.v10_15)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.2.0"), + .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/vapor", from: "4.89.0"), ], diff --git a/Examples/event-streams-server-example/Sources/EventStreamsServer/EventStreamsServer.swift b/Examples/event-streams-server-example/Sources/EventStreamsServer/EventStreamsServer.swift index 49498e7b..5672df8b 100644 --- a/Examples/event-streams-server-example/Sources/EventStreamsServer/EventStreamsServer.swift +++ b/Examples/event-streams-server-example/Sources/EventStreamsServer/EventStreamsServer.swift @@ -17,26 +17,26 @@ import Vapor struct Handler: APIProtocol { private let storage: StreamStorage = .init() - func getGreetingsStream(_ input: Operations.getGreetingsStream.Input) async throws - -> Operations.getGreetingsStream.Output + func getGreetingsStream(_ input: Operations.GetGreetingsStream.Input) async throws + -> Operations.GetGreetingsStream.Output { let name = input.query.name ?? "Stranger" let count = input.query.count ?? 10 let eventStream = storage.makeStream(name: name, count: count) - let responseBody: Operations.getGreetingsStream.Output.Ok.Body + let responseBody: Operations.GetGreetingsStream.Output.Ok.Body // Default to `application/jsonl`, if no other content type requested through the `Accept` header. - let chosenContentType = input.headers.accept.sortedByQuality().first ?? .init(contentType: .application_jsonl) + let chosenContentType = input.headers.accept.sortedByQuality().first ?? .init(contentType: .applicationJsonl) switch chosenContentType.contentType { - case .application_jsonl, .other: - responseBody = .application_jsonl( + case .applicationJsonl, .other: + responseBody = .applicationJsonl( .init(eventStream.asEncodedJSONLines(), length: .unknown, iterationBehavior: .single) ) - case .application_json_hyphen_seq: - responseBody = .application_json_hyphen_seq( + case .applicationJsonSeq: + responseBody = .applicationJsonSeq( .init(eventStream.asEncodedJSONSequence(), length: .unknown, iterationBehavior: .single) ) - case .text_event_hyphen_stream: - responseBody = .text_event_hyphen_stream( + case .textEventStream: + responseBody = .textEventStream( .init( eventStream.map { greeting in ServerSentEventWithJSONData( @@ -58,7 +58,7 @@ struct Handler: APIProtocol { @main struct EventStreamsServer { static func main() async throws { - let app = Vapor.Application() + let app = try await Vapor.Application.make() let transport = VaporTransport(routesBuilder: app) let handler = Handler() try handler.registerHandlers(on: transport, serverURL: URL(string: "/api")!) diff --git a/Examples/event-streams-server-example/Sources/EventStreamsServer/openapi-generator-config.yaml b/Examples/event-streams-server-example/Sources/EventStreamsServer/openapi-generator-config.yaml index f68d9c85..99d15462 100644 --- a/Examples/event-streams-server-example/Sources/EventStreamsServer/openapi-generator-config.yaml +++ b/Examples/event-streams-server-example/Sources/EventStreamsServer/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - server accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/hello-world-async-http-client-example/Package.swift b/Examples/hello-world-async-http-client-example/Package.swift index b3fa30c6..3f48edbe 100644 --- a/Examples/hello-world-async-http-client-example/Package.swift +++ b/Examples/hello-world-async-http-client-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "hello-world-async-http-client-example", platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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-async-http-client", from: "1.0.0"), ], targets: [ diff --git a/Examples/hello-world-async-http-client-example/Sources/HelloWorldAsyncHTTPClient/openapi-generator-config.yaml b/Examples/hello-world-async-http-client-example/Sources/HelloWorldAsyncHTTPClient/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/hello-world-async-http-client-example/Sources/HelloWorldAsyncHTTPClient/openapi-generator-config.yaml +++ b/Examples/hello-world-async-http-client-example/Sources/HelloWorldAsyncHTTPClient/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/hello-world-hummingbird-server-example/Package.swift b/Examples/hello-world-hummingbird-server-example/Package.swift index eff4c7e1..5afbc2b5 100644 --- a/Examples/hello-world-hummingbird-server-example/Package.swift +++ b/Examples/hello-world-hummingbird-server-example/Package.swift @@ -16,12 +16,12 @@ import PackageDescription let package = Package( name: "hello-world-hummingbird-server-example", - platforms: [.macOS(.v10_15)], + platforms: [.macOS(.v14)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), - .package(url: "https://github.com/swift-server/swift-openapi-hummingbird", from: "1.0.0"), - .package(url: "https://github.com/hummingbird-project/hummingbird", from: "1.10.1"), + .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/hummingbird", from: "2.5.0"), ], targets: [ .executableTarget( diff --git a/Examples/hello-world-hummingbird-server-example/Sources/HelloWorldHummingbirdServer/HelloWorldHummingbirdServer.swift b/Examples/hello-world-hummingbird-server-example/Sources/HelloWorldHummingbirdServer/HelloWorldHummingbirdServer.swift index e5695700..39dc89d7 100644 --- a/Examples/hello-world-hummingbird-server-example/Sources/HelloWorldHummingbirdServer/HelloWorldHummingbirdServer.swift +++ b/Examples/hello-world-hummingbird-server-example/Sources/HelloWorldHummingbirdServer/HelloWorldHummingbirdServer.swift @@ -17,7 +17,7 @@ import Hummingbird import Foundation struct Handler: APIProtocol { - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { let name = input.query.name ?? "Stranger" return .ok(.init(body: .json(.init(message: "Hello, \(name)!")))) } @@ -25,10 +25,10 @@ struct Handler: APIProtocol { @main struct HelloWorldHummingbirdServer { static func main() async throws { - let app = Hummingbird.HBApplication() - let transport = HBOpenAPITransport(app) + let router = Router() let handler = Handler() - try handler.registerHandlers(on: transport, serverURL: URL(string: "/api")!) - try await app.asyncRun() + try handler.registerHandlers(on: router, serverURL: URL(string: "/api")!) + let app = Application(router: router, configuration: .init()) + try await app.run() } } diff --git a/Examples/hello-world-hummingbird-server-example/Sources/HelloWorldHummingbirdServer/openapi-generator-config.yaml b/Examples/hello-world-hummingbird-server-example/Sources/HelloWorldHummingbirdServer/openapi-generator-config.yaml index f68d9c85..99d15462 100644 --- a/Examples/hello-world-hummingbird-server-example/Sources/HelloWorldHummingbirdServer/openapi-generator-config.yaml +++ b/Examples/hello-world-hummingbird-server-example/Sources/HelloWorldHummingbirdServer/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - server accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/hello-world-urlsession-client-example/Package.swift b/Examples/hello-world-urlsession-client-example/Package.swift index 505afc14..d3ceb729 100644 --- a/Examples/hello-world-urlsession-client-example/Package.swift +++ b/Examples/hello-world-urlsession-client-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "hello-world-urlsession-client-example", platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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"), ], targets: [ diff --git a/Examples/hello-world-urlsession-client-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml b/Examples/hello-world-urlsession-client-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/hello-world-urlsession-client-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml +++ b/Examples/hello-world-urlsession-client-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/hello-world-vapor-server-example/Package.swift b/Examples/hello-world-vapor-server-example/Package.swift index 00316e9f..d8c6c14d 100644 --- a/Examples/hello-world-vapor-server-example/Package.swift +++ b/Examples/hello-world-vapor-server-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "hello-world-vapor-server-example", platforms: [.macOS(.v10_15)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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/vapor", from: "4.89.0"), ], diff --git a/Examples/hello-world-vapor-server-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift b/Examples/hello-world-vapor-server-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift index de9d8c86..9e1b8e6a 100644 --- a/Examples/hello-world-vapor-server-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift +++ b/Examples/hello-world-vapor-server-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift @@ -16,7 +16,7 @@ import OpenAPIVapor import Vapor struct Handler: APIProtocol { - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { let name = input.query.name ?? "Stranger" return .ok(.init(body: .json(.init(message: "Hello, \(name)!")))) } @@ -24,7 +24,7 @@ struct Handler: APIProtocol { @main struct HelloWorldVaporServer { static func main() async throws { - let app = Vapor.Application() + let app = try await Vapor.Application.make() let transport = VaporTransport(routesBuilder: app) let handler = Handler() try handler.registerHandlers(on: transport, serverURL: URL(string: "/api")!) diff --git a/Examples/hello-world-vapor-server-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml b/Examples/hello-world-vapor-server-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml index f68d9c85..99d15462 100644 --- a/Examples/hello-world-vapor-server-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml +++ b/Examples/hello-world-vapor-server-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - server accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/logging-middleware-oslog-example/Package.swift b/Examples/logging-middleware-oslog-example/Package.swift index 90ca3019..b56c9e93 100644 --- a/Examples/logging-middleware-oslog-example/Package.swift +++ b/Examples/logging-middleware-oslog-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "logging-middleware-oslog-example", platforms: [.macOS(.v11), .iOS(.v14), .tvOS(.v14), .watchOS(.v7), .visionOS(.v1)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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/apple/swift-http-types", from: "1.0.2"), ], diff --git a/Examples/logging-middleware-oslog-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml b/Examples/logging-middleware-oslog-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/logging-middleware-oslog-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml +++ b/Examples/logging-middleware-oslog-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/logging-middleware-swift-log-example/Package.swift b/Examples/logging-middleware-swift-log-example/Package.swift index 205f5ffc..a2778721 100644 --- a/Examples/logging-middleware-swift-log-example/Package.swift +++ b/Examples/logging-middleware-swift-log-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "logging-middleware-swift-log-example", platforms: [.macOS(.v11), .iOS(.v14), .tvOS(.v14), .watchOS(.v7), .visionOS(.v1)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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/apple/swift-http-types", from: "1.0.2"), .package(url: "https://github.com/apple/swift-log", from: "1.5.3"), diff --git a/Examples/logging-middleware-swift-log-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml b/Examples/logging-middleware-swift-log-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/logging-middleware-swift-log-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml +++ b/Examples/logging-middleware-swift-log-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/manual-generation-generator-cli-example/Makefile b/Examples/manual-generation-generator-cli-example/Makefile index 2439e614..8448e80a 100644 --- a/Examples/manual-generation-generator-cli-example/Makefile +++ b/Examples/manual-generation-generator-cli-example/Makefile @@ -4,7 +4,7 @@ # The following values can be changed here, or passed on the command line. SWIFT_OPENAPI_GENERATOR_GIT_URL ?= https://github.com/apple/swift-openapi-generator -SWIFT_OPENAPI_GENERATOR_GIT_TAG ?= 1.5.0 +SWIFT_OPENAPI_GENERATOR_GIT_TAG ?= 1.6.0 SWIFT_OPENAPI_GENERATOR_CLONE_DIR ?= $(CURRENT_MAKEFILE_DIR)/.swift-openapi-generator SWIFT_OPENAPI_GENERATOR_BUILD_CONFIGURATION ?= debug OPENAPI_YAML_PATH ?= $(CURRENT_MAKEFILE_DIR)/openapi.yaml diff --git a/Examples/manual-generation-generator-cli-example/Package.swift b/Examples/manual-generation-generator-cli-example/Package.swift index 236bf2db..5195108f 100644 --- a/Examples/manual-generation-generator-cli-example/Package.swift +++ b/Examples/manual-generation-generator-cli-example/Package.swift @@ -18,7 +18,7 @@ let package = Package( name: "manual-generation-generator-cli-example", platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.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"), ], targets: [ diff --git a/Examples/manual-generation-generator-cli-example/Sources/ManualGeneratorInvocationClient/Generated/Client.swift b/Examples/manual-generation-generator-cli-example/Sources/ManualGeneratorInvocationClient/Generated/Client.swift index 7ca90d80..bb6d2911 100644 --- a/Examples/manual-generation-generator-cli-example/Sources/ManualGeneratorInvocationClient/Generated/Client.swift +++ b/Examples/manual-generation-generator-cli-example/Sources/ManualGeneratorInvocationClient/Generated/Client.swift @@ -39,10 +39,10 @@ internal struct Client: APIProtocol { } /// - Remark: HTTP `GET /greet`. /// - Remark: Generated from `#/paths//greet/get(getGreeting)`. - internal func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + internal func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { try await client.send( input: input, - forOperation: Operations.getGreeting.id, + forOperation: Operations.GetGreeting.id, serializer: { input in let path = try converter.renderedPath( template: "/greet", @@ -70,7 +70,7 @@ internal struct Client: APIProtocol { switch response.status.code { case 200: let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) - let body: Operations.getGreeting.Output.Ok.Body + let body: Operations.GetGreeting.Output.Ok.Body let chosenContentType = try converter.bestContentType( received: contentType, options: [ diff --git a/Examples/manual-generation-generator-cli-example/Sources/ManualGeneratorInvocationClient/Generated/Types.swift b/Examples/manual-generation-generator-cli-example/Sources/ManualGeneratorInvocationClient/Generated/Types.swift index f930e8ca..71e1f59f 100644 --- a/Examples/manual-generation-generator-cli-example/Sources/ManualGeneratorInvocationClient/Generated/Types.swift +++ b/Examples/manual-generation-generator-cli-example/Sources/ManualGeneratorInvocationClient/Generated/Types.swift @@ -13,7 +13,7 @@ import struct Foundation.Date internal protocol APIProtocol: Sendable { /// - Remark: HTTP `GET /greet`. /// - Remark: Generated from `#/paths//greet/get(getGreeting)`. - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output } /// Convenience overloads for operation inputs. @@ -21,10 +21,10 @@ extension APIProtocol { /// - Remark: HTTP `GET /greet`. /// - Remark: Generated from `#/paths//greet/get(getGreeting)`. internal func getGreeting( - query: Operations.getGreeting.Input.Query = .init(), - headers: Operations.getGreeting.Input.Headers = .init() - ) async throws -> Operations.getGreeting.Output { - try await getGreeting(Operations.getGreeting.Input( + query: Operations.GetGreeting.Input.Query = .init(), + headers: Operations.GetGreeting.Input.Headers = .init() + ) async throws -> Operations.GetGreeting.Output { + try await getGreeting(Operations.GetGreeting.Input( query: query, headers: headers )) @@ -91,7 +91,7 @@ internal enum Components { internal enum Operations { /// - Remark: HTTP `GET /greet`. /// - Remark: Generated from `#/paths//greet/get(getGreeting)`. - internal enum getGreeting { + internal enum GetGreeting { internal static let id: Swift.String = "getGreeting" internal struct Input: Sendable, Hashable { /// - Remark: Generated from `#/paths/greet/GET/query`. @@ -108,27 +108,27 @@ internal enum Operations { self.name = name } } - internal var query: Operations.getGreeting.Input.Query + internal var query: Operations.GetGreeting.Input.Query /// - Remark: Generated from `#/paths/greet/GET/header`. internal struct Headers: Sendable, Hashable { - internal var accept: [OpenAPIRuntime.AcceptHeaderContentType] + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType] /// Creates a new `Headers`. /// /// - Parameters: /// - accept: - internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType] = .defaultValues()) { + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType] = .defaultValues()) { self.accept = accept } } - internal var headers: Operations.getGreeting.Input.Headers + internal var headers: Operations.GetGreeting.Input.Headers /// Creates a new `Input`. /// /// - Parameters: /// - query: /// - headers: internal init( - query: Operations.getGreeting.Input.Query = .init(), - headers: Operations.getGreeting.Input.Headers = .init() + query: Operations.GetGreeting.Input.Query = .init(), + headers: Operations.GetGreeting.Input.Headers = .init() ) { self.query = query self.headers = headers @@ -154,12 +154,12 @@ internal enum Operations { } } /// Received HTTP response body - internal var body: Operations.getGreeting.Output.Ok.Body + internal var body: Operations.GetGreeting.Output.Ok.Body /// Creates a new `Ok`. /// /// - Parameters: /// - body: Received HTTP response body - internal init(body: Operations.getGreeting.Output.Ok.Body) { + internal init(body: Operations.GetGreeting.Output.Ok.Body) { self.body = body } } @@ -168,12 +168,12 @@ internal enum Operations { /// - Remark: Generated from `#/paths//greet/get(getGreeting)/responses/200`. /// /// HTTP response code: `200 ok`. - case ok(Operations.getGreeting.Output.Ok) + case ok(Operations.GetGreeting.Output.Ok) /// The associated value of the enum case if `self` is `.ok`. /// /// - Throws: An error if `self` is not `.ok`. /// - SeeAlso: `.ok`. - internal var ok: Operations.getGreeting.Output.Ok { + internal var ok: Operations.GetGreeting.Output.Ok { get throws { switch self { case let .ok(response): diff --git a/Examples/manual-generation-generator-cli-example/openapi-generator-config.yaml b/Examples/manual-generation-generator-cli-example/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/manual-generation-generator-cli-example/openapi-generator-config.yaml +++ b/Examples/manual-generation-generator-cli-example/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/manual-generation-package-plugin-example/Package.swift b/Examples/manual-generation-package-plugin-example/Package.swift index 11980c75..a29635a9 100644 --- a/Examples/manual-generation-package-plugin-example/Package.swift +++ b/Examples/manual-generation-package-plugin-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "manual-generation-package-plugin-example", platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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"), ], targets: [ diff --git a/Examples/manual-generation-package-plugin-example/Sources/CommandPluginInvocationClient/GeneratedSources/Client.swift b/Examples/manual-generation-package-plugin-example/Sources/CommandPluginInvocationClient/GeneratedSources/Client.swift index 7ca90d80..bb6d2911 100644 --- a/Examples/manual-generation-package-plugin-example/Sources/CommandPluginInvocationClient/GeneratedSources/Client.swift +++ b/Examples/manual-generation-package-plugin-example/Sources/CommandPluginInvocationClient/GeneratedSources/Client.swift @@ -39,10 +39,10 @@ internal struct Client: APIProtocol { } /// - Remark: HTTP `GET /greet`. /// - Remark: Generated from `#/paths//greet/get(getGreeting)`. - internal func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + internal func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { try await client.send( input: input, - forOperation: Operations.getGreeting.id, + forOperation: Operations.GetGreeting.id, serializer: { input in let path = try converter.renderedPath( template: "/greet", @@ -70,7 +70,7 @@ internal struct Client: APIProtocol { switch response.status.code { case 200: let contentType = converter.extractContentTypeIfPresent(in: response.headerFields) - let body: Operations.getGreeting.Output.Ok.Body + let body: Operations.GetGreeting.Output.Ok.Body let chosenContentType = try converter.bestContentType( received: contentType, options: [ diff --git a/Examples/manual-generation-package-plugin-example/Sources/CommandPluginInvocationClient/GeneratedSources/Types.swift b/Examples/manual-generation-package-plugin-example/Sources/CommandPluginInvocationClient/GeneratedSources/Types.swift index f930e8ca..71e1f59f 100644 --- a/Examples/manual-generation-package-plugin-example/Sources/CommandPluginInvocationClient/GeneratedSources/Types.swift +++ b/Examples/manual-generation-package-plugin-example/Sources/CommandPluginInvocationClient/GeneratedSources/Types.swift @@ -13,7 +13,7 @@ import struct Foundation.Date internal protocol APIProtocol: Sendable { /// - Remark: HTTP `GET /greet`. /// - Remark: Generated from `#/paths//greet/get(getGreeting)`. - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output } /// Convenience overloads for operation inputs. @@ -21,10 +21,10 @@ extension APIProtocol { /// - Remark: HTTP `GET /greet`. /// - Remark: Generated from `#/paths//greet/get(getGreeting)`. internal func getGreeting( - query: Operations.getGreeting.Input.Query = .init(), - headers: Operations.getGreeting.Input.Headers = .init() - ) async throws -> Operations.getGreeting.Output { - try await getGreeting(Operations.getGreeting.Input( + query: Operations.GetGreeting.Input.Query = .init(), + headers: Operations.GetGreeting.Input.Headers = .init() + ) async throws -> Operations.GetGreeting.Output { + try await getGreeting(Operations.GetGreeting.Input( query: query, headers: headers )) @@ -91,7 +91,7 @@ internal enum Components { internal enum Operations { /// - Remark: HTTP `GET /greet`. /// - Remark: Generated from `#/paths//greet/get(getGreeting)`. - internal enum getGreeting { + internal enum GetGreeting { internal static let id: Swift.String = "getGreeting" internal struct Input: Sendable, Hashable { /// - Remark: Generated from `#/paths/greet/GET/query`. @@ -108,27 +108,27 @@ internal enum Operations { self.name = name } } - internal var query: Operations.getGreeting.Input.Query + internal var query: Operations.GetGreeting.Input.Query /// - Remark: Generated from `#/paths/greet/GET/header`. internal struct Headers: Sendable, Hashable { - internal var accept: [OpenAPIRuntime.AcceptHeaderContentType] + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType] /// Creates a new `Headers`. /// /// - Parameters: /// - accept: - internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType] = .defaultValues()) { + internal init(accept: [OpenAPIRuntime.AcceptHeaderContentType] = .defaultValues()) { self.accept = accept } } - internal var headers: Operations.getGreeting.Input.Headers + internal var headers: Operations.GetGreeting.Input.Headers /// Creates a new `Input`. /// /// - Parameters: /// - query: /// - headers: internal init( - query: Operations.getGreeting.Input.Query = .init(), - headers: Operations.getGreeting.Input.Headers = .init() + query: Operations.GetGreeting.Input.Query = .init(), + headers: Operations.GetGreeting.Input.Headers = .init() ) { self.query = query self.headers = headers @@ -154,12 +154,12 @@ internal enum Operations { } } /// Received HTTP response body - internal var body: Operations.getGreeting.Output.Ok.Body + internal var body: Operations.GetGreeting.Output.Ok.Body /// Creates a new `Ok`. /// /// - Parameters: /// - body: Received HTTP response body - internal init(body: Operations.getGreeting.Output.Ok.Body) { + internal init(body: Operations.GetGreeting.Output.Ok.Body) { self.body = body } } @@ -168,12 +168,12 @@ internal enum Operations { /// - Remark: Generated from `#/paths//greet/get(getGreeting)/responses/200`. /// /// HTTP response code: `200 ok`. - case ok(Operations.getGreeting.Output.Ok) + case ok(Operations.GetGreeting.Output.Ok) /// The associated value of the enum case if `self` is `.ok`. /// /// - Throws: An error if `self` is not `.ok`. /// - SeeAlso: `.ok`. - internal var ok: Operations.getGreeting.Output.Ok { + internal var ok: Operations.GetGreeting.Output.Ok { get throws { switch self { case let .ok(response): diff --git a/Examples/manual-generation-package-plugin-example/Sources/CommandPluginInvocationClient/openapi-generator-config.yaml b/Examples/manual-generation-package-plugin-example/Sources/CommandPluginInvocationClient/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/manual-generation-package-plugin-example/Sources/CommandPluginInvocationClient/openapi-generator-config.yaml +++ b/Examples/manual-generation-package-plugin-example/Sources/CommandPluginInvocationClient/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/metrics-middleware-example/Package.swift b/Examples/metrics-middleware-example/Package.swift index 95154c3c..3b73c2e9 100644 --- a/Examples/metrics-middleware-example/Package.swift +++ b/Examples/metrics-middleware-example/Package.swift @@ -18,12 +18,12 @@ let package = Package( name: "metrics-middleware-example", platforms: [.macOS(.v13)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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/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", exact: "2.0.0-alpha.1"), + .package(url: "https://github.com/swift-server/swift-prometheus", from: "2.0.0"), ], targets: [ .target( diff --git a/Examples/metrics-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift b/Examples/metrics-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift index b7eda2ab..c4951b83 100644 --- a/Examples/metrics-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift +++ b/Examples/metrics-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift @@ -19,7 +19,7 @@ import Metrics import Prometheus struct Handler: APIProtocol { - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { let name = input.query.name ?? "Stranger" return .ok(.init(body: .json(.init(message: "Hello, \(name)!")))) } @@ -30,7 +30,7 @@ struct Handler: APIProtocol { let registry = PrometheusCollectorRegistry() MetricsSystem.bootstrap(PrometheusMetricsFactory(registry: registry)) - let app = Vapor.Application() + let app = try await Vapor.Application.make() app.get("metrics") { request in var buffer: [UInt8] = [] diff --git a/Examples/metrics-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml b/Examples/metrics-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml index f68d9c85..99d15462 100644 --- a/Examples/metrics-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml +++ b/Examples/metrics-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - server accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/postgres-database-example/Package.swift b/Examples/postgres-database-example/Package.swift index 838ba144..de2a4f15 100644 --- a/Examples/postgres-database-example/Package.swift +++ b/Examples/postgres-database-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "postgres-database-example", platforms: [.macOS(.v10_15)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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/vapor", from: "4.89.0"), .package(url: "https://github.com/vapor/postgres-nio", from: "1.19.1"), diff --git a/Examples/postgres-database-example/Sources/PostgresDatabaseServer/PostgresDatabaseServer.swift b/Examples/postgres-database-example/Sources/PostgresDatabaseServer/PostgresDatabaseServer.swift index b3de8e70..d9eab3c5 100644 --- a/Examples/postgres-database-example/Sources/PostgresDatabaseServer/PostgresDatabaseServer.swift +++ b/Examples/postgres-database-example/Sources/PostgresDatabaseServer/PostgresDatabaseServer.swift @@ -47,7 +47,7 @@ actor Handler: APIProtocol { deinit { try? self.postgresConnection.close().wait() } - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { let name = input.query.name ?? "Stranger" let greeting = Components.Schemas.Greeting(message: "Hello, \(name)!") _ = try await self.postgresConnection.query( @@ -57,12 +57,12 @@ actor Handler: APIProtocol { return .ok(.init(body: .json(greeting))) } - func getCount(_ input: Operations.getCount.Input) async throws -> Operations.getCount.Output { + func getCount(_ input: Operations.GetCount.Input) async throws -> Operations.GetCount.Output { let count = try await self.postgresConnection.query("SELECT * FROM messages", logger: logger).collect().count return .ok(.init(body: .json(.init(count: count)))) } - func reset(_ input: Operations.reset.Input) async throws -> Operations.reset.Output { + func reset(_ input: Operations.Reset.Input) async throws -> Operations.Reset.Output { _ = try await self.postgresConnection.query("DELETE FROM messages", logger: logger) return .noContent(.init(body: .json(.init()))) } @@ -70,7 +70,7 @@ actor Handler: APIProtocol { @main struct HelloWorldVaporServer { static func main() async throws { - let app = Vapor.Application() + let app = try await Vapor.Application.make() let transport = VaporTransport(routesBuilder: app) let handler = try await Handler() try handler.registerHandlers(on: transport, serverURL: URL(string: "/api")!) diff --git a/Examples/postgres-database-example/Sources/PostgresDatabaseServer/openapi-generator-config.yaml b/Examples/postgres-database-example/Sources/PostgresDatabaseServer/openapi-generator-config.yaml index f68d9c85..99d15462 100644 --- a/Examples/postgres-database-example/Sources/PostgresDatabaseServer/openapi-generator-config.yaml +++ b/Examples/postgres-database-example/Sources/PostgresDatabaseServer/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - server accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/retrying-middleware-example/Package.swift b/Examples/retrying-middleware-example/Package.swift index 4875e972..feceab1e 100644 --- a/Examples/retrying-middleware-example/Package.swift +++ b/Examples/retrying-middleware-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "hello-world-urlsession-client-example", platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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/apple/swift-http-types", from: "1.0.2"), ], diff --git a/Examples/retrying-middleware-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml b/Examples/retrying-middleware-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/retrying-middleware-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml +++ b/Examples/retrying-middleware-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/shared-types-client-server-example/Package.swift b/Examples/shared-types-client-server-example/Package.swift index 524cc9f6..89ca6158 100644 --- a/Examples/shared-types-client-server-example/Package.swift +++ b/Examples/shared-types-client-server-example/Package.swift @@ -16,16 +16,16 @@ import PackageDescription let package = Package( name: "shared-types-client-server-example", - platforms: [.macOS(.v13)], + platforms: [.macOS(.v14)], products: [ .executable(name: "hello-world-client", targets: ["Client"]), .executable(name: "hello-world-server", targets: ["Server"]), ], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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: "1.0.0"), + .package(url: "https://github.com/swift-server/swift-openapi-hummingbird", from: "2.0.0"), ], targets: [ .target( diff --git a/Examples/shared-types-client-server-example/Sources/Client/openapi-generator-config.yaml b/Examples/shared-types-client-server-example/Sources/Client/openapi-generator-config.yaml index c8205b30..285bf5f9 100644 --- a/Examples/shared-types-client-server-example/Sources/Client/openapi-generator-config.yaml +++ b/Examples/shared-types-client-server-example/Sources/Client/openapi-generator-config.yaml @@ -1,5 +1,6 @@ generate: - client accessModifier: internal +namingStrategy: idiomatic additionalImports: - Types diff --git a/Examples/shared-types-client-server-example/Sources/Server/HelloWorldHummingbirdServer.swift b/Examples/shared-types-client-server-example/Sources/Server/HelloWorldHummingbirdServer.swift index e2650754..686368fd 100644 --- a/Examples/shared-types-client-server-example/Sources/Server/HelloWorldHummingbirdServer.swift +++ b/Examples/shared-types-client-server-example/Sources/Server/HelloWorldHummingbirdServer.swift @@ -18,7 +18,7 @@ import Foundation import Types struct Handler: APIProtocol { - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { let name = input.query.name ?? "Stranger" let message = Components.Schemas.Greeting(message: "Hello, \(name)!") return .ok(.init(body: .json(message.boxed()))) @@ -27,10 +27,10 @@ struct Handler: APIProtocol { @main struct HelloWorldHummingbirdServer { static func main() async throws { - let app = Hummingbird.HBApplication() - let transport = HBOpenAPITransport(app) + let router = Router() let handler = Handler() - try handler.registerHandlers(on: transport, serverURL: URL(string: "/api")!) - try await app.asyncRun() + try handler.registerHandlers(on: router, serverURL: URL(string: "/api")!) + let app = Application(router: router, configuration: .init()) + try await app.run() } } diff --git a/Examples/shared-types-client-server-example/Sources/Server/openapi-generator-config.yaml b/Examples/shared-types-client-server-example/Sources/Server/openapi-generator-config.yaml index 0e38ae57..31d787b8 100644 --- a/Examples/shared-types-client-server-example/Sources/Server/openapi-generator-config.yaml +++ b/Examples/shared-types-client-server-example/Sources/Server/openapi-generator-config.yaml @@ -1,5 +1,6 @@ generate: - server accessModifier: internal +namingStrategy: idiomatic additionalImports: - Types diff --git a/Examples/shared-types-client-server-example/Sources/Types/openapi-generator-config.yaml b/Examples/shared-types-client-server-example/Sources/Types/openapi-generator-config.yaml index 7e4ffe46..a12e67bf 100644 --- a/Examples/shared-types-client-server-example/Sources/Types/openapi-generator-config.yaml +++ b/Examples/shared-types-client-server-example/Sources/Types/openapi-generator-config.yaml @@ -1,3 +1,4 @@ generate: - types accessModifier: package +namingStrategy: idiomatic diff --git a/Examples/swagger-ui-endpoint-example/Package.swift b/Examples/swagger-ui-endpoint-example/Package.swift index eec1978f..63e7f5dc 100644 --- a/Examples/swagger-ui-endpoint-example/Package.swift +++ b/Examples/swagger-ui-endpoint-example/Package.swift @@ -15,13 +15,13 @@ import PackageDescription let package = Package( - name: "hello-world-urlsession-client-example", + name: "swagger-ui-endpoint-example", platforms: [.macOS(.v10_15)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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/vapor", from: "4.89.0"), + .package(url: "https://github.com/vapor/vapor", from: "4.108.0"), ], targets: [ .executableTarget( diff --git a/Examples/swagger-ui-endpoint-example/Sources/SwaggerUIEndpointsServer/SwaggerUIEndpointsServer.swift b/Examples/swagger-ui-endpoint-example/Sources/SwaggerUIEndpointsServer/SwaggerUIEndpointsServer.swift index 227f88d3..bd1d59ca 100644 --- a/Examples/swagger-ui-endpoint-example/Sources/SwaggerUIEndpointsServer/SwaggerUIEndpointsServer.swift +++ b/Examples/swagger-ui-endpoint-example/Sources/SwaggerUIEndpointsServer/SwaggerUIEndpointsServer.swift @@ -16,7 +16,7 @@ import OpenAPIVapor import Vapor struct Handler: APIProtocol { - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { let name = input.query.name ?? "Stranger" return .ok(.init(body: .json(.init(message: "Hello, \(name)!")))) } @@ -24,7 +24,7 @@ struct Handler: APIProtocol { @main struct SwaggerUIEndpointsServer { static func main() async throws { - let app = Vapor.Application() + let app = try await Vapor.Application.make() let transport = VaporTransport(routesBuilder: app) // Register the handlers generated from the OpenAPI document. diff --git a/Examples/swagger-ui-endpoint-example/Sources/SwaggerUIEndpointsServer/openapi-generator-config.yaml b/Examples/swagger-ui-endpoint-example/Sources/SwaggerUIEndpointsServer/openapi-generator-config.yaml index f68d9c85..99d15462 100644 --- a/Examples/swagger-ui-endpoint-example/Sources/SwaggerUIEndpointsServer/openapi-generator-config.yaml +++ b/Examples/swagger-ui-endpoint-example/Sources/SwaggerUIEndpointsServer/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - server accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/tracing-middleware-example/Package.swift b/Examples/tracing-middleware-example/Package.swift index 0f7f9ad7..83158c50 100644 --- a/Examples/tracing-middleware-example/Package.swift +++ b/Examples/tracing-middleware-example/Package.swift @@ -18,14 +18,14 @@ let package = Package( name: "tracing-middleware-example", platforms: [.macOS(.v13)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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/vapor", from: "4.89.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"), .package(url: "https://github.com/apple/swift-nio", from: "2.62.0"), - .package(url: "https://github.com/slashmo/swift-otel", .upToNextMinor(from: "0.8.0")), + .package(url: "https://github.com/swift-otel/swift-otel", .upToNextMinor(from: "0.10.1")), ], targets: [ .target( @@ -42,8 +42,8 @@ let package = Package( "TracingMiddleware", .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"), .product(name: "OpenAPIVapor", package: "swift-openapi-vapor"), .product(name: "Vapor", package: "vapor"), .product(name: "NIO", package: "swift-nio"), - .product(name: "OpenTelemetry", package: "swift-otel"), - .product(name: "OtlpGRPCSpanExporting", package: "swift-otel"), + .product(name: "OTel", package: "swift-otel"), + .product(name: "OTLPGRPC", package: "swift-otel"), ], plugins: [.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator")] ), diff --git a/Examples/tracing-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift b/Examples/tracing-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift index c49b4fe3..8b7971b6 100644 --- a/Examples/tracing-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift +++ b/Examples/tracing-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift @@ -16,12 +16,12 @@ import OpenAPIVapor import Vapor import TracingMiddleware import Tracing -import OpenTelemetry -import OtlpGRPCSpanExporting +import OTel +import OTLPGRPC import NIO struct Handler: APIProtocol { - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { let name = input.query.name ?? "Stranger" return .ok(.init(body: .json(.init(message: "Hello, \(name)!")))) } @@ -29,23 +29,46 @@ struct Handler: APIProtocol { @main struct HelloWorldVaporServer { static func main() async throws { - let eventLoopGroup = MultiThreadedEventLoopGroup.singleton - let otel = OTel( - serviceName: "HelloWorldServer", - eventLoopGroup: eventLoopGroup, - processor: OTel.BatchSpanProcessor( - exportingTo: OtlpGRPCSpanExporter(config: .init(eventLoopGroup: eventLoopGroup)), - eventLoopGroup: eventLoopGroup - ) + let environment = OTelEnvironment.detected() + let resourceDetection = OTelResourceDetection(detectors: [ + OTelProcessResourceDetector(), + OTelEnvironmentResourceDetector(environment: environment), + ]) + let resource = await resourceDetection.resource(environment: environment, logLevel: .trace) + let exporter = try OTLPGRPCSpanExporter(configuration: .init(environment: environment)) + let processor = OTelBatchSpanProcessor(exporter: exporter, configuration: .init(environment: environment)) + let tracer = OTelTracer( + idGenerator: OTelRandomIDGenerator(), + sampler: OTelConstantSampler(isOn: true), + propagator: OTelW3CPropagator(), + processor: processor, + environment: environment, + resource: resource ) - try await otel.start().get() - defer { try? otel.shutdown().wait() } - InstrumentationSystem.bootstrap(otel.tracer()) - - let app = Vapor.Application() + InstrumentationSystem.bootstrap(tracer) + + let app = try await Vapor.Application.make() let transport = VaporTransport(routesBuilder: app) let handler = Handler() - try handler.registerHandlers(on: transport, serverURL: URL(string: "/api")!, middlewares: [TracingMiddleware()]) - try await app.execute() + try handler.registerHandlers( + on: transport, + serverURL: URL(string: "/api")!, + middlewares: [ + TracingMiddleware() + ] + ) + try await withThrowingTaskGroup(of: Void.self) { group in + group.addTask { + try await app.execute() + } + group.addTask { + try await tracer.run() + } + group.addTask { + try await processor.run() + } + _ = try await group.next() + group.cancelAll() + } } } diff --git a/Examples/tracing-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml b/Examples/tracing-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml index f68d9c85..99d15462 100644 --- a/Examples/tracing-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml +++ b/Examples/tracing-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - server accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/various-content-types-client-example/Package.swift b/Examples/various-content-types-client-example/Package.swift index 0046a279..f6e8bbef 100644 --- a/Examples/various-content-types-client-example/Package.swift +++ b/Examples/various-content-types-client-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "various-content-types-client-example", platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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"), ], targets: [ diff --git a/Examples/various-content-types-client-example/Sources/ContentTypesClient/ContentTypesClient.swift b/Examples/various-content-types-client-example/Sources/ContentTypesClient/ContentTypesClient.swift index f96e4789..30c91293 100644 --- a/Examples/various-content-types-client-example/Sources/ContentTypesClient/ContentTypesClient.swift +++ b/Examples/various-content-types-client-example/Sources/ContentTypesClient/ContentTypesClient.swift @@ -105,7 +105,7 @@ import Foundation case .names(let name): let stringName = try await String(collecting: name.payload.body, upTo: 1024) // Multipart parts can have headers. - let locale = name.payload.headers.x_hyphen_name_hyphen_locale ?? "" + let locale = name.payload.headers.xNameLocale ?? "" print("Received a name: '\(stringName)', header value: '\(locale)'") case .undocumented(let part): // Any part with a raw HTTPBody body must have its body consumed before moving on to the next part. @@ -117,9 +117,9 @@ import Foundation } } do { - let multipartBody: MultipartBody = [ + let multipartBody: MultipartBody = [ .greetingTemplate(.init(payload: .init(body: .init(message: "Hello, {name}!")))), - .names(.init(payload: .init(headers: .init(x_hyphen_name_hyphen_locale: "en_US"), body: "Frank"))), + .names(.init(payload: .init(headers: .init(xNameLocale: "en_US"), body: "Frank"))), .names(.init(payload: .init(body: "Not Frank"))), ] let response = try await client.postExampleMultipart(body: .multipartForm(multipartBody)) diff --git a/Examples/various-content-types-client-example/Sources/ContentTypesClient/openapi-generator-config.yaml b/Examples/various-content-types-client-example/Sources/ContentTypesClient/openapi-generator-config.yaml index 1df6f287..ee9d836c 100644 --- a/Examples/various-content-types-client-example/Sources/ContentTypesClient/openapi-generator-config.yaml +++ b/Examples/various-content-types-client-example/Sources/ContentTypesClient/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - client accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/various-content-types-server-example/Package.swift b/Examples/various-content-types-server-example/Package.swift index e43d770c..5db4bf91 100644 --- a/Examples/various-content-types-server-example/Package.swift +++ b/Examples/various-content-types-server-example/Package.swift @@ -18,8 +18,8 @@ let package = Package( name: "various-content-types-server-example", platforms: [.macOS(.v10_15)], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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/vapor", from: "4.89.0"), ], diff --git a/Examples/various-content-types-server-example/Sources/ContentTypesServer/ContentTypesServer.swift b/Examples/various-content-types-server-example/Sources/ContentTypesServer/ContentTypesServer.swift index dbff86d1..f5546d3e 100644 --- a/Examples/various-content-types-server-example/Sources/ContentTypesServer/ContentTypesServer.swift +++ b/Examples/various-content-types-server-example/Sources/ContentTypesServer/ContentTypesServer.swift @@ -17,13 +17,13 @@ import Vapor struct Handler: APIProtocol { - func getExampleJSON(_ input: Operations.getExampleJSON.Input) async throws -> Operations.getExampleJSON.Output { + func getExampleJSON(_ input: Operations.GetExampleJSON.Input) async throws -> Operations.GetExampleJSON.Output { let name = input.query.name ?? "Stranger" print("Greeting a person with the name: \(name)") return .ok(.init(body: .json(.init(message: "Hello, \(name)!")))) } - func postExampleJSON(_ input: Operations.postExampleJSON.Input) async throws -> Operations.postExampleJSON.Output { + func postExampleJSON(_ input: Operations.PostExampleJSON.Input) async throws -> Operations.PostExampleJSON.Output { let requestBody: Components.Schemas.Greeting switch input.body { case .json(let json): requestBody = json @@ -32,8 +32,8 @@ struct Handler: APIProtocol { return .accepted(.init()) } - func getExamplePlainText(_ input: Operations.getExamplePlainText.Input) async throws - -> Operations.getExamplePlainText.Output + func getExamplePlainText(_ input: Operations.GetExamplePlainText.Input) async throws + -> Operations.GetExamplePlainText.Output { .ok( .init( @@ -49,8 +49,8 @@ struct Handler: APIProtocol { ) } - func postExamplePlainText(_ input: Operations.postExamplePlainText.Input) async throws - -> Operations.postExamplePlainText.Output + func postExamplePlainText(_ input: Operations.PostExamplePlainText.Input) async throws + -> Operations.PostExamplePlainText.Output { let plainText: HTTPBody switch input.body { @@ -61,8 +61,8 @@ struct Handler: APIProtocol { return .accepted(.init()) } - func getExampleMultipleContentTypes(_ input: Operations.getExampleMultipleContentTypes.Input) async throws - -> Operations.getExampleMultipleContentTypes.Output + func getExampleMultipleContentTypes(_ input: Operations.GetExampleMultipleContentTypes.Input) async throws + -> Operations.GetExampleMultipleContentTypes.Output { // The Accept header field lets the client communicate which response content type it prefers, by giving // each content type a "quality" (in other words, a preference), from 0.0 to 1.0, from least to most preferred. @@ -72,7 +72,7 @@ struct Handler: APIProtocol { // As a server, here we sort the received content types in the Accept header by quality, from most to least // preferred. If none are provided, default to JSON. let chosenContentType = input.headers.accept.sortedByQuality().first?.contentType ?? .json - let responseBody: Operations.getExampleMultipleContentTypes.Output.Ok.Body + let responseBody: Operations.GetExampleMultipleContentTypes.Output.Ok.Body switch chosenContentType { case .json, .other: responseBody = .json(.init(message: "Hello, Stranger!")) case .plainText: responseBody = .plainText("Hello, Stranger!") @@ -80,8 +80,8 @@ struct Handler: APIProtocol { return .ok(.init(body: responseBody)) } - func postExampleMultipleContentTypes(_ input: Operations.postExampleMultipleContentTypes.Input) async throws - -> Operations.postExampleMultipleContentTypes.Output + func postExampleMultipleContentTypes(_ input: Operations.PostExampleMultipleContentTypes.Input) async throws + -> Operations.PostExampleMultipleContentTypes.Output { switch input.body { case .json(let json): print("Received a JSON greeting with the message: \(json.message)") @@ -92,10 +92,10 @@ struct Handler: APIProtocol { return .accepted(.init()) } - func postExampleURLEncoded(_ input: Operations.postExampleURLEncoded.Input) async throws - -> Operations.postExampleURLEncoded.Output + func postExampleURLEncoded(_ input: Operations.PostExampleURLEncoded.Input) async throws + -> Operations.PostExampleURLEncoded.Output { - let requestBody: Operations.postExampleURLEncoded.Input.Body.urlEncodedFormPayload + let requestBody: Operations.PostExampleURLEncoded.Input.Body.UrlEncodedFormPayload switch input.body { case .urlEncodedForm(let form): requestBody = form } @@ -103,12 +103,12 @@ struct Handler: APIProtocol { return .accepted(.init()) } - func getExampleRawBytes(_ input: Operations.getExampleRawBytes.Input) async throws - -> Operations.getExampleRawBytes.Output + func getExampleRawBytes(_ input: Operations.GetExampleRawBytes.Input) async throws + -> Operations.GetExampleRawBytes.Output { .ok(.init(body: .binary([0x73, 0x6e, 0x6f, 0x77, 0x0a]))) } - func postExampleRawBytes(_ input: Operations.postExampleRawBytes.Input) async throws - -> Operations.postExampleRawBytes.Output + func postExampleRawBytes(_ input: Operations.PostExampleRawBytes.Input) async throws + -> Operations.PostExampleRawBytes.Output { let binary: HTTPBody switch input.body { @@ -119,21 +119,21 @@ struct Handler: APIProtocol { return .accepted(.init()) } - func getExampleMultipart(_ input: Operations.getExampleMultipart.Input) async throws - -> Operations.getExampleMultipart.Output + func getExampleMultipart(_ input: Operations.GetExampleMultipart.Input) async throws + -> Operations.GetExampleMultipart.Output { - let multipartBody: MultipartBody = [ + let multipartBody: MultipartBody = [ .greetingTemplate(.init(payload: .init(body: .init(message: "Hello, {name}!")))), - .names(.init(payload: .init(headers: .init(x_hyphen_name_hyphen_locale: "en_US"), body: "Frank"))), + .names(.init(payload: .init(headers: .init(xNameLocale: "en_US"), body: "Frank"))), .names(.init(payload: .init(body: "Not Frank"))), ] return .ok(.init(body: .multipartForm(multipartBody))) } - func postExampleMultipart(_ input: Operations.postExampleMultipart.Input) async throws - -> Operations.postExampleMultipart.Output + func postExampleMultipart(_ input: Operations.PostExampleMultipart.Input) async throws + -> Operations.PostExampleMultipart.Output { - let multipartBody: MultipartBody + let multipartBody: MultipartBody switch input.body { case .multipartForm(let form): multipartBody = form } @@ -145,7 +145,7 @@ struct Handler: APIProtocol { case .names(let name): let stringName = try await String(collecting: name.payload.body, upTo: 1024) // Multipart parts can have headers. - let locale = name.payload.headers.x_hyphen_name_hyphen_locale ?? "" + let locale = name.payload.headers.xNameLocale ?? "" print("Received a name: '\(stringName)', header value: '\(locale)'") case .undocumented(let part): // Any part with a raw HTTPBody body must have its body consumed before moving on to the next part. @@ -159,7 +159,7 @@ struct Handler: APIProtocol { @main struct ContentTypesServer { static func main() async throws { - let app = Vapor.Application() + let app = try await Vapor.Application.make() let transport = VaporTransport(routesBuilder: app) let handler = Handler() try handler.registerHandlers(on: transport, serverURL: URL(string: "/api")!) diff --git a/Examples/various-content-types-server-example/Sources/ContentTypesServer/openapi-generator-config.yaml b/Examples/various-content-types-server-example/Sources/ContentTypesServer/openapi-generator-config.yaml index f68d9c85..99d15462 100644 --- a/Examples/various-content-types-server-example/Sources/ContentTypesServer/openapi-generator-config.yaml +++ b/Examples/various-content-types-server-example/Sources/ContentTypesServer/openapi-generator-config.yaml @@ -2,3 +2,4 @@ generate: - types - server accessModifier: internal +namingStrategy: idiomatic diff --git a/Examples/various-content-types-server-example/Tests/ContentTypesServerTests/ContentTypesServerTests.swift b/Examples/various-content-types-server-example/Tests/ContentTypesServerTests/ContentTypesServerTests.swift index c57be07c..7eddc910 100644 --- a/Examples/various-content-types-server-example/Tests/ContentTypesServerTests/ContentTypesServerTests.swift +++ b/Examples/various-content-types-server-example/Tests/ContentTypesServerTests/ContentTypesServerTests.swift @@ -110,7 +110,7 @@ final class ContentTypesServerTests: XCTestCase { let handler: APIProtocol = Handler() let response = try await handler.getExampleMultipart() let multipartBody = try response.ok.body.multipartForm - var parts: [Operations.getExampleMultipart.Output.Ok.Body.multipartFormPayload] = [] + var parts: [Operations.GetExampleMultipart.Output.Ok.Body.MultipartFormPayload] = [] for try await part in multipartBody { parts.append(part) } XCTAssertEqual(parts.count, 3) } diff --git a/IntegrationTest/Package.swift b/IntegrationTest/Package.swift index 239e34fb..6cee5cd2 100644 --- a/IntegrationTest/Package.swift +++ b/IntegrationTest/Package.swift @@ -24,8 +24,8 @@ let package = Package( ) ], dependencies: [ - .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"), + .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"), ], targets: [ .target( diff --git a/IntegrationTest/Sources/Client/openapi-generator-config.yaml b/IntegrationTest/Sources/Client/openapi-generator-config.yaml index d553a2b1..69af6500 100644 --- a/IntegrationTest/Sources/Client/openapi-generator-config.yaml +++ b/IntegrationTest/Sources/Client/openapi-generator-config.yaml @@ -3,3 +3,4 @@ generate: additionalImports: - Types accessModifier: package +namingStrategy: idiomatic diff --git a/IntegrationTest/Sources/MockTransportServer/Server.swift b/IntegrationTest/Sources/MockTransportServer/Server.swift index e0c736ae..0f3fe556 100644 --- a/IntegrationTest/Sources/MockTransportServer/Server.swift +++ b/IntegrationTest/Sources/MockTransportServer/Server.swift @@ -17,7 +17,7 @@ import OpenAPIRuntime import HTTPTypes actor SimpleAPIImpl: APIProtocol { - func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output { + func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output { let message = "Hello, \(input.query.name ?? "Stranger")!" return .ok(.init(body: .json(.init(message: message)))) } diff --git a/IntegrationTest/Sources/Server/openapi-generator-config.yaml b/IntegrationTest/Sources/Server/openapi-generator-config.yaml index 7ccd1197..d4700ddf 100644 --- a/IntegrationTest/Sources/Server/openapi-generator-config.yaml +++ b/IntegrationTest/Sources/Server/openapi-generator-config.yaml @@ -3,3 +3,4 @@ generate: additionalImports: - Types accessModifier: package +namingStrategy: idiomatic diff --git a/IntegrationTest/Sources/Types/openapi-generator-config.yaml b/IntegrationTest/Sources/Types/openapi-generator-config.yaml index 7e4ffe46..a12e67bf 100644 --- a/IntegrationTest/Sources/Types/openapi-generator-config.yaml +++ b/IntegrationTest/Sources/Types/openapi-generator-config.yaml @@ -1,3 +1,4 @@ generate: - types accessModifier: package +namingStrategy: idiomatic