From 66ef974ae098b6bf9257967c348228eab9d154f0 Mon Sep 17 00:00:00 2001 From: Shalvah Date: Thu, 2 Dec 2021 12:46:43 +0100 Subject: [PATCH 1/2] Support httpApi payload override on handler --- src/ServerlessOffline.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ServerlessOffline.js b/src/ServerlessOffline.js index 5530c8d77..2c0a5c76a 100644 --- a/src/ServerlessOffline.js +++ b/src/ServerlessOffline.js @@ -369,10 +369,14 @@ export default class ServerlessOffline { } httpEvent.http.isHttpApi = true - httpEvent.http.payload = - service.provider.httpApi && service.provider.httpApi.payload - ? service.provider.httpApi.payload - : '2.0' + if (functionDefinition.httpApi && functionDefinition.httpApi.payload) { + httpEvent.http.payload = functionDefinition.httpApi.payload; + } else { + httpEvent.http.payload = + service.provider.httpApi && service.provider.httpApi.payload + ? service.provider.httpApi.payload + : '2.0' + } } if (http && http.private) { From f7dd72bdf6d49771d606c8958753dcd2d340201f Mon Sep 17 00:00:00 2001 From: shalvah Date: Thu, 2 Dec 2021 16:13:20 +0100 Subject: [PATCH 2/2] Fix formatting --- src/ServerlessOffline.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ServerlessOffline.js b/src/ServerlessOffline.js index 2c0a5c76a..2e0d8c44b 100644 --- a/src/ServerlessOffline.js +++ b/src/ServerlessOffline.js @@ -369,8 +369,11 @@ export default class ServerlessOffline { } httpEvent.http.isHttpApi = true - if (functionDefinition.httpApi && functionDefinition.httpApi.payload) { - httpEvent.http.payload = functionDefinition.httpApi.payload; + if ( + functionDefinition.httpApi && + functionDefinition.httpApi.payload + ) { + httpEvent.http.payload = functionDefinition.httpApi.payload } else { httpEvent.http.payload = service.provider.httpApi && service.provider.httpApi.payload