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

Use custom serializer options for responses instead of default one #1715

Closed
Nairda015 opened this issue Apr 3, 2024 · 7 comments
Closed
Labels
annotations feature-request A feature should be added or improved. p1 This is a high priority issue queued s Effort estimation: small

Comments

@Nairda015
Copy link

Nairda015 commented Apr 3, 2024

Describe the bug

I don't see a way to set serialization options on all responses from lambda

Expected Behavior

I can control serialization options of responses like DefaultIgnoreCondition

Current Behavior

Default serializer is used and I have no idea how to override it's behavior

Reproduction Steps

Create custom serializer like in this example with DefaultIgnoreCondition set to WhenWrittingNull and return json with null values

Possible Solution

Here I want to use serializer options from custom serializer like in this example instead of default one.
It will require changes in if check from first link and maybe here

Additional Information/Context

AWS .NET SDK and/or Package version used

Annotation.Framework 1.2

Targeted .NET Platform

.NET 6

Operating System and version

AmazonLinux

@Nairda015 Nairda015 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 3, 2024
@ashishdhingra ashishdhingra added feature-request A feature should be added or improved. module/lambda-client-lib needs-review and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 3, 2024
@ashishdhingra
Copy link
Contributor

ashishdhingra commented Apr 3, 2024

@Nairda015 Good afternoon. Have you tried using LambdaSerializer attribute at method/assembly level? Kindly refer GetSerializerInfoAttribute(), it appears to inspect for LambdaSerializerAttribute.

Thanks,
Ashish

@ashishdhingra ashishdhingra added annotations response-requested Waiting on additional info and feedback. Will move to close soon in 7 days. and removed module/lambda-client-lib needs-review labels Apr 3, 2024
@Nairda015
Copy link
Author

Yes I have LambdaSerializerAttribute on assembly level and it works as expected but to populate something different than null here you need to set SerializerJsonContextName and only place in code where it is set is in this strange if statement here

@ashishdhingra
Copy link
Contributor

Yes I have LambdaSerializerAttribute on assembly level and it works as expected but to populate something different than null here you need to set SerializerJsonContextName and only place in code where it is set is in this strange if statement here

Needs review.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to close soon in 7 days. label Apr 5, 2024
@normj
Copy link
Member

normj commented Apr 5, 2024

I agree this is a gap in Annotations to be able to customize the HTTP response body JSON serialization outside if using System.Text.Json's .NET attributes on your POCO for serialization customization.

How would you feel if we allowed adding an interface implementation into the dependency injection container for customizing the serialization options?

@Nairda015
Copy link
Author

Sounds good but why we can't reuse serialization options from custom serializer it is already there

(I updated the links in original comment because there was duplication instead of this example above)

@ashishdhingra
Copy link
Contributor

This should have been addressed via PR #1748 and available in Amazon.Lambda.Annotations v1.4.0 package.

Copy link
Contributor

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
annotations feature-request A feature should be added or improved. p1 This is a high priority issue queued s Effort estimation: small
Projects
None yet
Development

No branches or pull requests

3 participants