spring-cloud-function icon indicating copy to clipboard operation
spring-cloud-function copied to clipboard

JsonMapper bean is not used

Open Cedware opened this issue 2 years ago • 2 comments

Describe the bug In my spring-cloud function project I want to modify the behavior of the json serializer. In version 3.2.x of this project, this was possible by providing a bean of the type ObjectMapper. With the current version (4.0.4) this does not seem to work anymore. I also tried to provide a bean of the type JsonMapper, but this has no effect as well.

Sample

I provided a small example in this repository: https://github.com/Cedware/cloud-function-demo

In the CloudFunctionDemoApplication class I created a JsonMapper bean, where I configured the ObjectMapper to use snake case naming. The demo application can be started by running mvn package followed by mvn azure-functions:run After the application has started, you can send a get request to http://localhost:7071/api/test.

Since I configured the JsonMapper to use snake case naming, I expect the response to look like this:

{
  "some_property": "some string value"
}

But the actual result looks like this:

{
  "someProperty": "some string value"
}

Cedware avatar Jul 19 '23 09:07 Cedware

Thank you for the feedback @Cedware,

What I'm missing from the demo, though, is any Spring Cloud Function implementation that could be used inside the handler? If your say that the 3.2.x version worked can you please share the code?

tzolov avatar Jul 20 '23 10:07 tzolov

I just looked at your sample and I am confused.

return request.createResponseBuilder(HttpStatus.OK)
                .body(new TestResult("some string value"))
                .header("Content-Type", "application/json")
                .build();

Based on what I see this application does not use spring-sloud-function. I mean you are having it on classpath but you are not making any calls to s-c-function. Could you please clarify?

olegz avatar Oct 23 '23 14:10 olegz

This issue has been stale for over 60 days

github-actions[bot] avatar Oct 28 '24 17:10 github-actions[bot]