From 7b7368bec4f9b5bdeea2e41003f686eba9d1d475 Mon Sep 17 00:00:00 2001 From: Brian Diesel Date: Fri, 7 Feb 2025 14:21:04 -0500 Subject: [PATCH 1/3] Update README.md This commit fixes an issue when starting Vapor in swift 6. I believe earlier versions of Swift throw a warning about this. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b2f47dc..5ddb3663 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ struct Handler: APIProtocol { @main struct HelloWorldVaporServer { static func main() async throws { - let app = Vapor.Application() + let app = try await Application.make(.detect()) let transport = VaporTransport(routesBuilder: app) let handler = Handler() try handler.registerHandlers(on: transport, serverURL: URL(string: "/api")!) From b09348778d39ce7ce553897a26675a4dba33c3fb Mon Sep 17 00:00:00 2001 From: Brian Diesel Date: Fri, 7 Feb 2025 15:10:46 -0500 Subject: [PATCH 2/3] Update README.md Remove environment detection param --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ddb3663..18421481 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ struct Handler: APIProtocol { @main struct HelloWorldVaporServer { static func main() async throws { - let app = try await Application.make(.detect()) + let app = try await Application.make() let transport = VaporTransport(routesBuilder: app) let handler = Handler() try handler.registerHandlers(on: transport, serverURL: URL(string: "/api")!) From b9db8820b1dff5cd2e12c63e9dd0549e25f5cc4a Mon Sep 17 00:00:00 2001 From: Brian Diesel Date: Fri, 7 Feb 2025 17:36:08 -0500 Subject: [PATCH 3/3] update all existing deprecated calls to Vapor.Application and replace with .make() for swift 6 compatibility --- .../Articles/Practicing-spec-driven-API-development.md | 10 +++++----- .../Documentation.docc/Swift-OpenAPI-Generator.md | 2 +- .../_Resources/server-openapi-endpoints.main.0.swift | 2 +- .../_Resources/server-openapi-endpoints.main.1.swift | 2 +- .../_Resources/server-openapi-endpoints.main.2.swift | 2 +- .../Tutorials/_Resources/server.main.1.2.swift | 2 +- .../Tutorials/_Resources/server.main.2.swift | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Sources/swift-openapi-generator/Documentation.docc/Articles/Practicing-spec-driven-API-development.md b/Sources/swift-openapi-generator/Documentation.docc/Articles/Practicing-spec-driven-API-development.md index 9df7bc06..8482871b 100644 --- a/Sources/swift-openapi-generator/Documentation.docc/Articles/Practicing-spec-driven-API-development.md +++ b/Sources/swift-openapi-generator/Documentation.docc/Articles/Practicing-spec-driven-API-development.md @@ -138,7 +138,7 @@ This example starts with a [Vapor](https://github.com/vapor/vapor) server that h The existing server might look something like this: ```swift -let app = Vapor.Application() +let app = try await Vapor.Application.make() app.get("foo") { ... a, b, c ... } app.post("foo") { ... a, b, c ... } app.get("bar") { ... a, b, c ... } @@ -173,7 +173,7 @@ As you go through the tutorial, the important part is that you only _add_ the ge After this step, your code looks something like this: ```swift -let app = Vapor.Application() +let app = try await Vapor.Application.make() // Registers your existing routes. app.get("foo") { ... a, b, c ... } @@ -216,7 +216,7 @@ paths: Comment out the first of the existing route implementations in your Vapor app: ```swift -let app = Vapor.Application() +let app = try await Vapor.Application.make() // Registers your existing routes. // app.get("foo") { ... a, b, c ... } // <<< just comment this out, and this route will be registered below by registerHandlers, as it is now defined by your OpenAPI document. @@ -236,7 +236,7 @@ When you compile the example above, you'll get a build error because `APIProtoco Xcode will offer a Fix-it, and if you accept it, it will drop in a function stub that you can fill in: ```swift -let app = Vapor.Application() +let app = try await Vapor.Application.make() // Registers your existing routes. // <<< now you can just delete the first original route, as you've moved the business logic below into the Handler type @@ -271,7 +271,7 @@ Endpoints that provide static content, such as CSS or JavaScript files, are not The end result should look something like this: ```swift -let app = Vapor.Application() +let app = try await Vapor.Application.make() // Register some manual routes, for example, for serving static files. app.middlewares.on(FileMiddleware(...)) diff --git a/Sources/swift-openapi-generator/Documentation.docc/Swift-OpenAPI-Generator.md b/Sources/swift-openapi-generator/Documentation.docc/Swift-OpenAPI-Generator.md index 9dda5b47..840f808e 100644 --- a/Sources/swift-openapi-generator/Documentation.docc/Swift-OpenAPI-Generator.md +++ b/Sources/swift-openapi-generator/Documentation.docc/Swift-OpenAPI-Generator.md @@ -65,7 +65,7 @@ struct Handler: APIProtocol { @main struct HelloWorldVaporServer { static func main() async throws { - let app = Vapor.Application() + let app = try await Application.make() let transport = VaporTransport(routesBuilder: app) let handler = Handler() try handler.registerHandlers(on: transport, serverURL: URL(string: "/api")!) diff --git a/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server-openapi-endpoints.main.0.swift b/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server-openapi-endpoints.main.0.swift index 3052468d..aed69e93 100644 --- a/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server-openapi-endpoints.main.0.swift +++ b/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server-openapi-endpoints.main.0.swift @@ -15,7 +15,7 @@ struct GreetingServiceAPIImpl: APIProtocol { } // Create your Vapor application. -let app = Vapor.Application() +let app = try await Vapor.Application.make() // Create a VaporTransport using your application. let transport = VaporTransport(routesBuilder: app) diff --git a/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server-openapi-endpoints.main.1.swift b/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server-openapi-endpoints.main.1.swift index 24cead5f..5a0ca45b 100644 --- a/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server-openapi-endpoints.main.1.swift +++ b/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server-openapi-endpoints.main.1.swift @@ -15,7 +15,7 @@ struct GreetingServiceAPIImpl: APIProtocol { } // Create your Vapor application. -let app = Vapor.Application() +let app = try await Vapor.Application.make() // Create a VaporTransport using your application. let transport = VaporTransport(routesBuilder: app) diff --git a/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server-openapi-endpoints.main.2.swift b/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server-openapi-endpoints.main.2.swift index c296fcb7..f72a3c62 100644 --- a/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server-openapi-endpoints.main.2.swift +++ b/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server-openapi-endpoints.main.2.swift @@ -15,7 +15,7 @@ struct GreetingServiceAPIImpl: APIProtocol { } // Create your Vapor application. -let app = Vapor.Application() +let app = try await Vapor.Application.make() // Create a VaporTransport using your application. let transport = VaporTransport(routesBuilder: app) diff --git a/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server.main.1.2.swift b/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server.main.1.2.swift index 3052468d..aed69e93 100644 --- a/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server.main.1.2.swift +++ b/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server.main.1.2.swift @@ -15,7 +15,7 @@ struct GreetingServiceAPIImpl: APIProtocol { } // Create your Vapor application. -let app = Vapor.Application() +let app = try await Vapor.Application.make() // Create a VaporTransport using your application. let transport = VaporTransport(routesBuilder: app) diff --git a/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server.main.2.swift b/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server.main.2.swift index 59a6149b..eea30fb1 100644 --- a/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server.main.2.swift +++ b/Sources/swift-openapi-generator/Documentation.docc/Tutorials/_Resources/server.main.2.swift @@ -23,7 +23,7 @@ struct GreetingServiceAPIImpl: APIProtocol { } // Create your Vapor application. -let app = Vapor.Application() +let app = try await Vapor.Application.make() // Create a VaporTransport using your application. let transport = VaporTransport(routesBuilder: app)