spring-cloud / spring-cloud-function

Apache License 2.0
1.03k stars 613 forks source link

JsonMapper bean is not used #1059

Open Cedware opened 1 year ago

Cedware commented 1 year ago

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"
}
tzolov commented 1 year ago

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?

olegz commented 10 months ago

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?