Skip to content

Commit f6e7af8

Browse files
Added support for contentHandling and passthrough
1 parent 86c66ad commit f6e7af8

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

lib/apiGateway/schema.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ const eventBridgeDetail = Joi.alternatives().try([
207207
])
208208

209209
const request = Joi.object({
210+
contentHandling: Joi.string()
211+
.valid('CONVERT_TO_BINARY', 'CONVERT_TO_TEXT'),
212+
passThrough: Joi.string()
213+
.valid('WHEN_NO_MATCH', 'NEVER', 'WHEN_NO_TEMPLATES'),
210214
template: Joi.object().required()
211215
})
212216

lib/apiGateway/validate.test.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,55 @@ describe('#validateServiceProxies()', () => {
814814
)
815815
})
816816
})
817+
818+
proxiesToTest.forEach(({ proxy, props }) => {
819+
it(`should not throw if a request contextHandling is set for ${proxy}`, () => {
820+
serverlessApigatewayServiceProxy.serverless.service.custom = {
821+
apiGatewayServiceProxies: [
822+
{
823+
[proxy]: Object.assign(
824+
{
825+
path: `/${proxy}`,
826+
method: 'post',
827+
request: { contextHandling: 'CONVERT_TO_TEXT' }
828+
},
829+
props
830+
)
831+
}
832+
]
833+
}
834+
835+
expect(() => serverlessApigatewayServiceProxy.validateServiceProxies()).to.not.throw(
836+
serverless.classes.Error,
837+
`child "${proxy}" fails because ["requestParameters" is not allowed]`
838+
)
839+
})
840+
})
841+
842+
proxiesToTest.forEach(({ proxy, props }) => {
843+
it(`should not throw if a request passthrough is set for ${proxy}`, () => {
844+
serverlessApigatewayServiceProxy.serverless.service.custom = {
845+
apiGatewayServiceProxies: [
846+
{
847+
[proxy]: Object.assign(
848+
{
849+
path: `/${proxy}`,
850+
method: 'post',
851+
request: { passthrough: 'WHEN_NO_TEMPLATES' }
852+
},
853+
props
854+
)
855+
}
856+
]
857+
}
858+
859+
expect(() => serverlessApigatewayServiceProxy.validateServiceProxies()).to.not.throw(
860+
serverless.classes.Error,
861+
`child "${proxy}" fails because ["requestParameters" is not allowed]`
862+
)
863+
})
864+
})
865+
817866
})
818867

819868
describe('kinesis', () => {

0 commit comments

Comments
 (0)