Skip to content

Commit fa43957

Browse files
committed
revert type to original commits off main
1 parent d6c9992 commit fa43957

File tree

2 files changed

+72
-70
lines changed

2 files changed

+72
-70
lines changed

Sources/AWSLambdaEvents/APIGateway+V2.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,69 +23,68 @@ public struct APIGatewayV2Request: Codable {
2323
public let sourceIp: String
2424
public let userAgent: String
2525
}
26-
26+
2727
/// Authorizer contains authorizer information for the request context.
2828
public struct Authorizer: Codable {
2929
/// JWT contains JWT authorizer information for the request context.
3030
public struct JWT: Codable {
3131
public let claims: [String: String]?
3232
public let scopes: [String]?
3333
}
34-
34+
3535
public let jwt: JWT
3636
}
37-
37+
3838
public let accountId: String
3939
public let apiId: String
4040
public let domainName: String
4141
public let domainPrefix: String
4242
public let stage: String
4343
public let requestId: String
44-
44+
4545
public let http: HTTP
4646
public let authorizer: Authorizer?
47-
47+
4848
/// The request time in format: 23/Apr/2020:11:08:18 +0000
4949
public let time: String
5050
public let timeEpoch: UInt64
5151
}
52-
52+
5353
public let version: String
5454
public let routeKey: String
5555
public let rawPath: String
5656
public let rawQueryString: String
57-
57+
5858
public let cookies: [String]?
5959
public let headers: HTTPHeaders
6060
public let queryStringParameters: [String: String]?
6161
public let pathParameters: [String: String]?
62-
62+
6363
public let context: Context
6464
public let stageVariables: [String: String]?
65-
65+
6666
public let body: String?
6767
public let isBase64Encoded: Bool
68-
68+
6969
enum CodingKeys: String, CodingKey {
7070
case version
7171
case routeKey
7272
case rawPath
7373
case rawQueryString
74-
74+
7575
case cookies
7676
case headers
7777
case queryStringParameters
7878
case pathParameters
79-
79+
8080
case context = "requestContext"
8181
case stageVariables
82-
82+
8383
case body
8484
case isBase64Encoded
8585
}
8686
}
8787

88-
8988
public struct APIGatewayV2Response: Codable {
9089
public var statusCode: HTTPResponseStatus
9190
public var headers: HTTPHeaders?
@@ -113,5 +112,6 @@ extension APIGatewayV2Request: Sendable {}
113112
extension APIGatewayV2Request.Context: Sendable {}
114113
extension APIGatewayV2Request.Context.HTTP: Sendable {}
115114
extension APIGatewayV2Request.Context.Authorizer: Sendable {}
115+
extension APIGatewayV2Request.Context.Authorizer.JWT: Sendable {}
116116
extension APIGatewayV2Response: Sendable {}
117117
#endif

Tests/AWSLambdaEventsTests/APIGateway+V2Tests.swift

Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,68 +17,70 @@ import XCTest
1717

1818
class APIGatewayV2Tests: XCTestCase {
1919
static let exampleGetEventBody = """
20-
{
21-
"routeKey":"GET /hello",
22-
"version":"2.0",
23-
"rawPath":"/hello",
24-
"stageVariables":{
25-
"foo":"bar"
26-
},
27-
"requestContext":{
28-
"timeEpoch":1587750461466,
29-
"domainPrefix":"hello",
30-
"authorizer":{
31-
"jwt":{
32-
"scopes":[
33-
"hello"
34-
],
35-
"claims":{
36-
"aud":"customers",
37-
"iss":"https://hello.test.com/",
38-
"iat":"1587749276",
39-
"exp":"1587756476"
40-
}
41-
}
42-
},
43-
"accountId":"0123456789",
44-
"stage":"$default",
45-
"domainName":"hello.test.com",
46-
"apiId":"pb5dg6g3rg",
47-
"requestId":"LgLpnibOFiAEPCA=",
48-
"http":{
49-
"path":"/hello",
50-
"userAgent":"Paw/3.1.10 (Macintosh; OS X/10.15.4) GCDHTTPRequest",
51-
"method":"GET",
52-
"protocol":"HTTP/1.1",
53-
"sourceIp":"91.64.117.86"
54-
},
55-
"time":"24/Apr/2020:17:47:41 +0000"
56-
},
57-
"isBase64Encoded":false,
58-
"rawQueryString":"foo=bar",
59-
"queryStringParameters":{
60-
"foo":"bar"
61-
},
62-
"headers":{
63-
"x-forwarded-proto":"https",
64-
"x-forwarded-for":"91.64.117.86",
65-
"x-forwarded-port":"443",
66-
"authorization":"Bearer abc123",
67-
"host":"hello.test.com",
68-
"x-amzn-trace-id":"Root=1-5ea3263d-07c5d5ddfd0788bed7dad831",
69-
"user-agent":"Paw/3.1.10 (Macintosh; OS X/10.15.4) GCDHTTPRequest",
70-
"content-length":"0"
71-
}
72-
}
73-
"""
74-
20+
{
21+
"routeKey":"GET /hello",
22+
"version":"2.0",
23+
"rawPath":"/hello",
24+
"stageVariables":{
25+
"foo":"bar"
26+
},
27+
"requestContext":{
28+
"timeEpoch":1587750461466,
29+
"domainPrefix":"hello",
30+
"authorizer":{
31+
"jwt":{
32+
"scopes":[
33+
"hello"
34+
],
35+
"claims":{
36+
"aud":"customers",
37+
"iss":"https://hello.test.com/",
38+
"iat":"1587749276",
39+
"exp":"1587756476"
40+
}
41+
}
42+
},
43+
"accountId":"0123456789",
44+
"stage":"$default",
45+
"domainName":"hello.test.com",
46+
"apiId":"pb5dg6g3rg",
47+
"requestId":"LgLpnibOFiAEPCA=",
48+
"http":{
49+
"path":"/hello",
50+
"userAgent":"Paw/3.1.10 (Macintosh; OS X/10.15.4) GCDHTTPRequest",
51+
"method":"GET",
52+
"protocol":"HTTP/1.1",
53+
"sourceIp":"91.64.117.86"
54+
},
55+
"time":"24/Apr/2020:17:47:41 +0000"
56+
},
57+
"isBase64Encoded":false,
58+
"rawQueryString":"foo=bar",
59+
"queryStringParameters":{
60+
"foo":"bar"
61+
},
62+
"headers":{
63+
"x-forwarded-proto":"https",
64+
"x-forwarded-for":"91.64.117.86",
65+
"x-forwarded-port":"443",
66+
"authorization":"Bearer abc123",
67+
"host":"hello.test.com",
68+
"x-amzn-trace-id":"Root=1-5ea3263d-07c5d5ddfd0788bed7dad831",
69+
"user-agent":"Paw/3.1.10 (Macintosh; OS X/10.15.4) GCDHTTPRequest",
70+
"content-length":"0"
71+
}
72+
}
73+
"""
74+
7575
// MARK: - Request -
76+
7677
// MARK: Decoding
78+
7779
func testRequestDecodingExampleGetRequest() {
7880
let data = APIGatewayV2Tests.exampleGetEventBody.data(using: .utf8)!
7981
var req: APIGatewayV2Request?
8082
XCTAssertNoThrow(req = try JSONDecoder().decode(APIGatewayV2Request.self, from: data))
81-
83+
8284
XCTAssertEqual(req?.rawPath, "/hello")
8385
XCTAssertEqual(req?.context.http.method, .GET)
8486
XCTAssertEqual(req?.queryStringParameters?.count, 1)

0 commit comments

Comments
 (0)