Skip to content

Commit 084fd86

Browse files
msailescarlzogh
andauthored
Add missing version field to APIGatewayProxyRequestEvent (#258)
Co-authored-by: Carl Zogheib <[email protected]>
1 parent cced9dc commit 084fd86

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java

+32
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public class APIGatewayProxyRequestEvent implements Serializable, Cloneable {
1111

1212
private static final long serialVersionUID = 4189228800688527467L;
1313

14+
private String version;
15+
1416
private String resource;
1517

1618
private String path;
@@ -903,6 +905,29 @@ public RequestIdentity clone() {
903905
*/
904906
public APIGatewayProxyRequestEvent() {}
905907

908+
/**
909+
* @return The payload format version
910+
*/
911+
public String getVersion() {
912+
return version;
913+
}
914+
915+
/**
916+
* @param version The payload format version
917+
*/
918+
public void setVersion(String version) {
919+
this.version = version;
920+
}
921+
922+
/**
923+
* @param version The payload format version
924+
* @return
925+
*/
926+
public APIGatewayProxyRequestEvent withVersion(String version) {
927+
this.setVersion(version);
928+
return this;
929+
}
930+
906931
/**
907932
* @return The resource path defined in API Gateway
908933
*/
@@ -1206,6 +1231,8 @@ public APIGatewayProxyRequestEvent withIsBase64Encoded(Boolean isBase64Encoded)
12061231
public String toString() {
12071232
StringBuilder sb = new StringBuilder();
12081233
sb.append("{");
1234+
if (getVersion() != null)
1235+
sb.append("version: ").append(getVersion()).append(",");
12091236
if (getResource() != null)
12101237
sb.append("resource: ").append(getResource()).append(",");
12111238
if (getPath() != null)
@@ -1244,6 +1271,10 @@ public boolean equals(Object obj) {
12441271
if (obj instanceof APIGatewayProxyRequestEvent == false)
12451272
return false;
12461273
APIGatewayProxyRequestEvent other = (APIGatewayProxyRequestEvent) obj;
1274+
if (other.getVersion() == null ^ this.getVersion() == null)
1275+
return false;
1276+
if (other.getVersion() != null && other.getVersion().equals(this.getVersion()) == false)
1277+
return false;
12471278
if (other.getResource() == null ^ this.getResource() == null)
12481279
return false;
12491280
if (other.getResource() != null && other.getResource().equals(this.getResource()) == false)
@@ -1300,6 +1331,7 @@ public int hashCode() {
13001331
final int prime = 31;
13011332
int hashCode = 1;
13021333

1334+
hashCode = prime * hashCode + ((getVersion() == null) ? 0 : getVersion().hashCode());
13031335
hashCode = prime * hashCode + ((getResource() == null) ? 0 : getResource().hashCode());
13041336
hashCode = prime * hashCode + ((getPath() == null) ? 0 : getPath().hashCode());
13051337
hashCode = prime * hashCode + ((getHttpMethod() == null) ? 0 : getHttpMethod().hashCode());

aws-lambda-java-serialization/src/test/resources/event_models/api_gateway_proxy_request_event.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"version": "1.0",
23
"path": "/test/hello",
34
"headers": {
45
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",

0 commit comments

Comments
 (0)