Unable to get FromQuery to work
- Dominant language
- C#
- Stars
- 1.7k
- Forks
- 503
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 18
Description
### Describe the bug
I created a REST API using lambda annotations. The FromBody works like charm, but I found that FromQuery annotation didn't work like expected. It gives me null value instead of object.
### Expected Behavior
FromQuery should works like FromBody
### Current Behavior
It doesn't work.
### Reproduction Steps
I created a lambda function like below.
```csharp
public class TestQueryParamsDto
{
public string x { get; set; } = "hello";
public string y { get; set; }
}
[LambdaFunction(ResourceName = "TestQueryParams", Policies = "AdministratorAccess")]
[RestApi(LambdaHttpMethod.Get, "/api/test-query-params")]
public APIGatewayProxyResponse TestQueryParams(APIGatewayProxyRequest request, [FromQuery] TestQueryParamsDto query)
{
var response = new APIGatewayProxyResponse();
response.StatusCode = 200;
response.Body = JsonSerializer.Serialize(new
{
message = "OK",
request = request,
query = query
});
return response;
}
```
After I test it in lambda-test-tool, I get the query argument unexpectedly has null value instead of object. Same thing happen to published functions.
Sample function input for lambda test tool:
```
{
"resource": "/{proxy+}",
"path": "/path/to/resource",
"httpMethod": "GET",
"queryStringParameters": {
"x": "abc",
"y": "abc"
},
"pathParameters": {
"proxy": "path/to/resource"
},
"stageVariables": {
"baz": "qux"
},
"headers": {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate, sdch",
"Accept-Language": "en-US,en;q=0.8",
"Cache-Control": "max-age=0",
"CloudFront-Forwarded-Proto": "https",
"CloudFront-Is-Desktop-Viewer": "true",
"CloudFront-Is-Mobile-Viewer": "false",
"CloudFront-Is-SmartTV-Viewer": "false",
"CloudFront-Is-Tablet-Viewer": "false",
"CloudFront-Viewer-Country": "US",
"Host": "1234567890.execute-api.{dns_suffix}",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Custom User Agent String",
"Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)",
"X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==",
"X-Forwarded-For": "127.0.0.1, 127.0.0.2",
"X-Forwarded-Port": "443",
"X-Forwarded-Proto": "https"
},
"requestContext": {
"accountId": "123456789012",
"resourceId": "123456",
"stage": "prod",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
"identity": {
"cognitoIdentityPoolId": null,
"accountId": null,
"cognitoIdentityId": null,
"caller": null,
"apiKey": null,
"sourceIp": "127.0.0.1",
"cognitoAuthenticationType": null,
"cognitoAuthenticationProvider": null,
"userArn": null,
"userAgent": "Custom User Agent String",
"user": null
},
"resourcePath": "/{proxy+}",
"httpMethod": "POST",
"apiId": "1234567890"
}
}
```
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### AWS .NET SDK and/or Package version used
```
net6.0
true
Lambda
true
Debug;Release;DEV
```
### Targeted .NET Platform
.NET 6 (C#/PowerShell)
### Operating System and version
Windows 10
Contributor guide
Assessment
This issue has not been assessed yet.