I'm not familiar enough with AWS to verify whether the syntax for mapping requestParameters is correct for AWS Swagger 2.0 config. The message will be send to SQS with a body like this
{
"QueueUrl": "https://sqs.us-east-1.amazonaws.com/177715257436/MyQueue/",
"MessageBody": "This is a test message",
"MessageAttributes": {
"EndpointURL": {
"DataType": "String",
"Value": "my_attribute_value_1"
}
}
}
I have the next config for Swagger 2.0. The main thing here is requestParameters, where MessageAttributes.EndpointURL.Value is remmapped to -> "method.request.header.EndpointURL". I expect to receive this value in EndpointURL Header for my method. Also, I set a default value for this Header(EndpointURL) with endpoint path value.
/test:
post:
consumes:
- "application/json"
parameters:
- name: EndpointURL
in: header
type: string
default: '/test'
produces:
- "application/json"
responses:
200:
description: "200 response"
schema:
$ref: "#/definitions/TestDto"
x-amazon-apigateway-integration:
credentials: "{{RoleARN}}"
uri: "uri"
responses:
default:
statusCode: "200"
requestParameters:
integration.request.body.MessageBody: "method.request.body.MessageBody"
integration.request.body.MessageAttributes.EndpointAddress.Value: "method.request.header.EndpointURL"
passthroughBehavior: "when_no_match"
httpMethod: "POST"
type: "aws"
Next question
1 Can anyone verify/check whether this is correct syntax for remapping values from integration.request.body.MessageAttributes to method.request.header.EndpointURL. ?
2 If it's correct I expect to receive this Header value in a method for SQS Listener.
@SqsListener(value = "${messaging.service-queue-url}")
public void onMessage(String message, @Header("EndpointURL") String endpointUrl) {
}
I used next docs https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html#SQS-SendMessage-request-MessageAttributes
https://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html
Thank you.