Skip to content

Commit 9c01b32

Browse files
Update Examples and IntegrationTest to use idiomatic naming (#706)
### Motivation Since idiomatic naming is our new recommended setting, use it in Examples and IntegrationTest. ### Modifications Added idiomatic naming to all examples and made any necessary changes. Plus a few modernizations, like moving to Hummingbird 2.0 and to Prometheus 2.0. ### Result More up-to-date examples, easier to copy out by adopters, they now get our recommended starting settings. ### Test Plan Ran and tested locally. --------- Co-authored-by: Si Beaumont <[email protected]>
1 parent dcfb1ed commit 9c01b32

File tree

82 files changed

+244
-204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+244
-204
lines changed

Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,15 +609,15 @@
609609
repositoryURL = "https://github.com/apple/swift-openapi-generator.git";
610610
requirement = {
611611
kind = upToNextMajorVersion;
612-
minimumVersion = 1.0.0;
612+
minimumVersion = 1.6.0;
613613
};
614614
};
615615
3A133D0E2B1F2A600008DD5E /* XCRemoteSwiftPackageReference "swift-openapi-runtime" */ = {
616616
isa = XCRemoteSwiftPackageReference;
617617
repositoryURL = "https://github.com/apple/swift-openapi-runtime.git";
618618
requirement = {
619619
kind = upToNextMajorVersion;
620-
minimumVersion = 1.0.0;
620+
minimumVersion = 1.7.0;
621621
};
622622
};
623623
3A133D112B1F2A730008DD5E /* XCRemoteSwiftPackageReference "swift-openapi-urlsession" */ = {

Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct ContentView: View {
6060

6161
// A mock client used in previews and tests to avoid making live network calls.
6262
struct MockClient: APIProtocol {
63-
func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output {
63+
func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output {
6464
let name = input.query.name ?? "Stranger"
6565
return .ok(.init(body: .json(.init(message: "(Mock) Hello, \(name)!"))))
6666
}

Examples/HelloWorldiOSClientAppExample/HelloWorldiOSClientApp/openapi-generator-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ generate:
22
- types
33
- client
44
accessModifier: internal
5+
namingStrategy: idiomatic

Examples/auth-client-middleware-example/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ let package = Package(
1818
name: "auth-client-middleware-example",
1919
platforms: [.macOS(.v11), .iOS(.v14), .tvOS(.v14), .watchOS(.v7), .visionOS(.v1)],
2020
dependencies: [
21-
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
22-
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
21+
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
22+
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
2323
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
2424
.package(url: "https://github.com/apple/swift-http-types", from: "1.0.2"),
2525
],

Examples/auth-client-middleware-example/Sources/HelloWorldURLSessionClient/openapi-generator-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ generate:
22
- types
33
- client
44
accessModifier: internal
5+
namingStrategy: idiomatic

Examples/auth-server-middleware-example/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ let package = Package(
1818
name: "auth-server-middleware-example",
1919
platforms: [.macOS(.v10_15)],
2020
dependencies: [
21-
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
22-
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
21+
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
22+
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
2323
.package(url: "https://github.com/swift-server/swift-openapi-vapor", from: "1.0.0"),
2424
.package(url: "https://github.com/vapor/vapor", from: "4.89.0"),
2525
],

Examples/auth-server-middleware-example/Sources/HelloWorldVaporServer/HelloWorldVaporServer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Vapor
1717
import AuthenticationServerMiddleware
1818

1919
struct Handler: APIProtocol {
20-
func getGreeting(_ input: Operations.getGreeting.Input) async throws -> Operations.getGreeting.Output {
20+
func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output {
2121
// Extract the authenticated user, if present.
2222
// If unauthenticated, return the 401 HTTP status code.
2323
// Note that the 401 is defined in the OpenAPI document, allowing the client
@@ -32,7 +32,7 @@ struct Handler: APIProtocol {
3232

3333
@main struct HelloWorldVaporServer {
3434
static func main() async throws {
35-
let app = Vapor.Application()
35+
let app = try await Vapor.Application.make()
3636
let transport = VaporTransport(routesBuilder: app)
3737
let handler = Handler()
3838
try handler.registerHandlers(

Examples/auth-server-middleware-example/Sources/HelloWorldVaporServer/openapi-generator-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ generate:
22
- types
33
- server
44
accessModifier: internal
5+
namingStrategy: idiomatic

Examples/bidirectional-event-streams-client-example/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ let package = Package(
1818
name: "bidirectional-event-streams-client-example",
1919
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)],
2020
dependencies: [
21-
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
22-
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.2.0"),
21+
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
22+
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
2323
.package(url: "https://github.com/swift-server/swift-openapi-async-http-client", from: "1.0.0"),
2424
],
2525
targets: [

Examples/bidirectional-event-streams-client-example/Sources/BidirectionalEventStreamsClient/BidirectionalEventStreamsClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import Foundation
2727
let (stream, continuation) = AsyncStream<Components.Schemas.Greeting>.makeStream()
2828
/// To keep it simple, using JSON Lines, as it most straightforward and easy way to have streams.
2929
/// For SSE and JSON Sequences cases please check `event-streams-client-example`.
30-
let requestBody: Operations.getGreetingsStream.Input.Body = .application_jsonl(
30+
let requestBody: Operations.GetGreetingsStream.Input.Body = .applicationJsonl(
3131
.init(stream.asEncodedJSONLines(), length: .unknown, iterationBehavior: .single)
3232
)
3333
let response = try await client.getGreetingsStream(query: .init(name: "Example"), body: requestBody)
34-
let greetingStream = try response.ok.body.application_jsonl.asDecodedJSONLines(
34+
let greetingStream = try response.ok.body.applicationJsonl.asDecodedJSONLines(
3535
of: Components.Schemas.Greeting.self
3636
)
3737
try await withThrowingTaskGroup(of: Void.self) { group in

0 commit comments

Comments
 (0)