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

Expected behavior for empty lists with @httpQuery trait #1608

Closed
xytxxx opened this issue Feb 8, 2023 · 1 comment
Closed

Expected behavior for empty lists with @httpQuery trait #1608

xytxxx opened this issue Feb 8, 2023 · 1 comment

Comments

@xytxxx
Copy link

xytxxx commented Feb 8, 2023

Hi team,
What the expected behavior is for marshalling an empty list in the AWS JSON protocols? I am trying to pass an empty array through http query but it gets marshalled to null (no http query is sent) by the Java Client.
Here is field that I am trying to send empty array with:

  @httpQuery("personId")
  personIds: IdList

And here is my API gateway integration:

uri: "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/{{{SendRequisitionToApproversLambda_Arn}}}/invocations",
httpMethod: "POST",
passThroughBehavior: "when_no_match",
type: "aws",
requestTemplates: {"application/json" :
    "#set ($root=$input.path('$'))
    {
     ......
      #if($method.request.multivaluequerystring.get('personId').size() > 0)
      \"personIds\": [
        #foreach($id in $method.request.multivaluequerystring.get('personId'))
        #if($id.length()!=0)\"$id\"#if($foreach.hasNext), #end#end
        #end
      ],#end
      ...
    }",
@srchase
Copy link
Contributor

srchase commented Feb 24, 2023

See the tests added in #1629

When serializing an empty string for param Foo, Foo= is serialized in the query string. An empty list for param Foo cannot also be serialized as Foo= as one might expect. Instead, it is omitted to clearly differentiate between an empty string, and an empty list.

@srchase srchase closed this as completed Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants