Skip to content

Commit b5eacd0

Browse files
committed
swift format and license
1 parent 24580d4 commit b5eacd0

File tree

2 files changed

+72
-56
lines changed

2 files changed

+72
-56
lines changed

Examples/quoteapi/Package.swift

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,41 @@
44
import PackageDescription
55

66
let package = Package(
7-
name: "QuoteService",
8-
platforms: [
9-
.macOS(.v13), .iOS(.v15), .tvOS(.v15), .watchOS(.v6),
10-
],
11-
products: [
12-
.executable(name: "QuoteService", targets: ["QuoteService"]),
13-
],
14-
dependencies: [
15-
.package(url: "https://github.com/apple/swift-openapi-generator.git", from: "1.4.0"),
16-
.package(url: "https://github.com/apple/swift-openapi-runtime.git", from: "1.5.0"),
17-
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha.3"),
18-
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", from: "0.4.0"),
19-
.package(url: "https://github.com/swift-server/swift-openapi-lambda.git", from: "0.2.0")
20-
// .package(name: "swift-openapi-lambda", path: "../swift-openapi-lambda")
21-
],
22-
targets: [
23-
.executableTarget(
24-
name: "QuoteService",
25-
dependencies: [
26-
.product(name: "OpenAPIRuntime",package: "swift-openapi-runtime"),
27-
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
28-
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
29-
.product(name: "OpenAPILambda",package: "swift-openapi-lambda"),
30-
],
31-
path: "Sources",
32-
resources: [
33-
.copy("openapi.yaml"),
34-
.copy("openapi-generator-config.yaml")
35-
],
36-
plugins: [
37-
.plugin(
38-
name: "OpenAPIGenerator",
39-
package: "swift-openapi-generator"
7+
name: "QuoteService",
8+
platforms: [
9+
.macOS(.v13), .iOS(.v15), .tvOS(.v15), .watchOS(.v6),
10+
],
11+
products: [
12+
.executable(name: "QuoteService", targets: ["QuoteService"])
13+
],
14+
dependencies: [
15+
.package(url: "https://github.com/apple/swift-openapi-generator.git", from: "1.4.0"),
16+
.package(url: "https://github.com/apple/swift-openapi-runtime.git", from: "1.5.0"),
17+
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "1.0.0-alpha.3"),
18+
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", from: "0.4.0"),
19+
.package(url: "https://github.com/swift-server/swift-openapi-lambda.git", from: "0.2.0"),
20+
// .package(name: "swift-openapi-lambda", path: "../swift-openapi-lambda")
21+
],
22+
targets: [
23+
.executableTarget(
24+
name: "QuoteService",
25+
dependencies: [
26+
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
27+
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
28+
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
29+
.product(name: "OpenAPILambda", package: "swift-openapi-lambda"),
30+
],
31+
path: "Sources",
32+
resources: [
33+
.copy("openapi.yaml"),
34+
.copy("openapi-generator-config.yaml"),
35+
],
36+
plugins: [
37+
.plugin(
38+
name: "OpenAPIGenerator",
39+
package: "swift-openapi-generator"
40+
)
41+
]
4042
)
41-
]
42-
)
43-
]
43+
]
4444
)
Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,49 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift OpenAPI Lambda open source project
4+
//
5+
// Copyright (c) 2023 Amazon.com, Inc. or its affiliates
6+
// and the Swift OpenAPI Lambda project authors
7+
// Licensed under Apache License v2.0
8+
//
9+
// See LICENSE.txt for license information
10+
// See CONTRIBUTORS.txt for the list of Swift OpenAPI Lambda project authors
11+
//
12+
// SPDX-License-Identifier: Apache-2.0
13+
//
14+
//===----------------------------------------------------------------------===//
15+
116
import Foundation
217
import OpenAPIRuntime
318
import OpenAPILambda
419

520
@main
621
struct QuoteServiceImpl: APIProtocol, OpenAPILambdaHttpApi {
722

8-
init(transport: OpenAPILambdaTransport) throws {
9-
try self.registerHandlers(on: transport)
10-
}
23+
init(transport: OpenAPILambdaTransport) throws {
24+
try self.registerHandlers(on: transport)
25+
}
1126

12-
func getQuote(_ input: Operations.getQuote.Input) async throws -> Operations.getQuote.Output {
27+
func getQuote(_ input: Operations.getQuote.Input) async throws -> Operations.getQuote.Output {
1328

14-
let symbol = input.path.symbol
29+
let symbol = input.path.symbol
1530

16-
var date: Date = Date()
17-
if let dateString = input.query.date {
18-
let dateFormatter = DateFormatter()
19-
dateFormatter.dateFormat = "yyyyMMdd"
20-
date = dateFormatter.date(from: dateString) ?? Date()
21-
}
31+
var date: Date = Date()
32+
if let dateString = input.query.date {
33+
let dateFormatter = DateFormatter()
34+
dateFormatter.dateFormat = "yyyyMMdd"
35+
date = dateFormatter.date(from: dateString) ?? Date()
36+
}
2237

23-
let price = Components.Schemas.quote(
24-
symbol: symbol,
25-
price: Double.random(in: 100..<150).rounded(),
26-
change: Double.random(in: -5..<5).rounded(),
27-
changePercent: Double.random(in: -0.05..<0.05),
28-
volume: Double.random(in: 10000..<100000).rounded(),
29-
timestamp: date)
38+
let price = Components.Schemas.quote(
39+
symbol: symbol,
40+
price: Double.random(in: 100..<150).rounded(),
41+
change: Double.random(in: -5..<5).rounded(),
42+
changePercent: Double.random(in: -0.05..<0.05),
43+
volume: Double.random(in: 10000..<100000).rounded(),
44+
timestamp: date
45+
)
3046

31-
return .ok(.init(body: .json(price)))
32-
}
47+
return .ok(.init(body: .json(price)))
48+
}
3349
}

0 commit comments

Comments
 (0)