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

jackson-dataformat-xml changed the default response content type from 'application/json' to 'application/xml' #530

Closed
VampireDaniel opened this issue May 28, 2022 · 2 comments
Labels
documentation Documentation-related task

Comments

@VampireDaniel
Copy link

VampireDaniel commented May 28, 2022

Hello project maintainer

This is a really good module and helps us a lot in our java application, which some API need to response with XML

But during the integration with this module in our java spring boot application, some APIs response content type got unexpected changed from 'application/json' to 'application/xml' when no indication in HTTP content. before added this module everything would be returned in JSON, and everything works fine and well.

So after some research, seems some people have same issue as well,
https://stackoverflow.com/questions/41036377/spring-mvc-changing-default-response-format-from-xml-to-json
https://stackoverflow.com/questions/66752245/spring-5-jackson-dataformat-xml-forces-responsebody-with-xml
https://stackoverflow.com/questions/57706610/how-to-set-default-messageconverter-to-json-with-jackson-dataformat-xml-added

The issue is easy to resolve, either to ask the client to indicate the Accept in header or add a limitation in Java service side, both work.
But the reason still want to raise an issue here is to purpose, can the project maintainer add maybe one Warning Section/Headsup Section on the Readme page to let all of the developers know, there might have one potential check on API response after leveraging this module.

Thanks a lot.

@cowtowncoder
Copy link
Member

cowtowncoder commented May 28, 2022

Knowing this module, I cannot see this happening due to anything this module does. Format module does absolutely nothing to Spring: Spring uses this module, not the other way around.
Module does not have any dependency to any Spring library and so does not even have means to directly change behavior.
But the opposite is not true: Spring framework may well use auto-detection and change its behavior based on existence of Jackson modules. If so, Spring is in control of any changes. This seems to me to be the likeliest scenario.

So please ask on Spring users lists or support forums: jackson-dataformat-xml knows nothing about whether and how Spring framework changes its behavior based on Jackson format modules it finds.

I would be happy to add some verbiage on READMEs -- ideally links to something that explains the issue -- once the issue is understood. But at this point it is not clear to me what specifically happens. I can only speculate that Spring has auto-detection of Jackson modules and thereby does something that changes some behavior.
But this really has everything to do with Spring; so this part needs to be understood.

Finally, please notice that there is another Jackson module -- jackson-jaxrs-xml-provider from https://github.com/FasterXML/jackson-jaxrs-providers/ -- that does register handlers to JAX-RS frameworks (which Spring might use via Jersey?). But it does not sound like you are adding that module.

@cowtowncoder cowtowncoder added the documentation Documentation-related task label May 28, 2022
@VampireDaniel
Copy link
Author

@cowtowncoder Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation-related task
Projects
None yet
Development

No branches or pull requests

2 participants