Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SQS's special URL format #21

Merged
merged 1 commit into from Apr 17, 2019

Conversation

Projects
None yet
2 participants
@pimterry
Copy link
Contributor

commented Apr 15, 2019

Annoyingly, SQS has it's own funky special logic for its QueueUrl parameter. It's not sent as a normal parameter - instead it's used to replace the entire base endpoint for the request. This only applies to requests for a specific queue (e.g. sending/receiving messages). To illustrate:

  • An SQS ReceiveMessage request with the current specs in theory should look like
    https://sqs.us-east-2.amazonaws.com/?Action=ReceiveMessage&QueueUrl=https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue/
    
  • In reality, the correct request would be:
    https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue/?Action=ReceiveMessage
    

I.e. the queue url replaces the base endpoint. You can see the SDK logic for this here: https://github.com/aws/aws-sdk-js/blob/bdcca26/lib/services/sqs.js#L120-L129. Fortunately, the queue url actually always consists of an SQS endpoint + /{AccountNumber}/{QueueName} (see https://docs.aws.amazon.com/sdk-for-net/v2/developer-guide/QueueURL.html).

To fix this, I just turn any QueueUrl params for the sqs spec into two extra path parameters (AccountNumber & QueueName), and then I remove the QueueUrl param entirely.

In practice, this means that:

paths:
  /#Action=ReceiveMessage:
    parameters:
      - name: QueueUrl
        in: query
        required: true
        description: <p>The URL of the Amazon SQS queue from which messages are received.</p> <p>Queue URLs and names are case-sensitive.</p>
        type: string

now becomes

paths:
  /{AccountNumber}/{QueueName}/#Action=ReceiveMessage:
    parameters:
      - in: path
        name: AccountNumber
        required: true
        description: The AWS account number
        type: integer
      - in: path
        name: QueueName
        required: true
        description: The name of the queue
        type: string

@MikeRalphson MikeRalphson merged commit e8c0e8b into APIs-guru:master Apr 17, 2019

@MikeRalphson

This comment has been minimized.

Copy link
Contributor

commented Apr 17, 2019

Thanks once more!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.