Skip to content

Commit f7ce36e

Browse files
committed
feat(dynamodb): allow custom request template definition
1 parent 2858498 commit f7ce36e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/apiGateway/schema.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ const proxiesSchemas = {
278278
tableName: stringOrRef.required(),
279279
condition: Joi.string(),
280280
hashKey: dynamodbDefaultKeyScheme.required(),
281-
rangeKey: dynamodbDefaultKeyScheme
281+
rangeKey: dynamodbDefaultKeyScheme,
282+
request
282283
})
283284
}),
284285
eventbridge: Joi.object({

lib/apiGateway/validate.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,5 +2169,24 @@ describe('#validateServiceProxies()', () => {
21692169

21702170
expect(() => serverlessApigatewayServiceProxy.validateServiceProxies()).to.not.throw()
21712171
})
2172+
2173+
it('should not throw error if request is a mapping template object', () => {
2174+
serverlessApigatewayServiceProxy.serverless.service.custom = {
2175+
apiGatewayServiceProxies: [
2176+
{
2177+
dynamodb: {
2178+
tableName: 'yourTable',
2179+
path: 'dynamodb',
2180+
method: 'put',
2181+
action: 'PutItem',
2182+
hashKey: { pathParam: 'id', attributeType: 'S' },
2183+
request: { template: { 'application/json': 'mapping template' } }
2184+
}
2185+
}
2186+
]
2187+
}
2188+
2189+
expect(() => serverlessApigatewayServiceProxy.validateServiceProxies()).to.not.throw()
2190+
})
21722191
})
21732192
})

0 commit comments

Comments
 (0)