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

Default Media Type application/xml is selected by default #2671

Closed
x-carrier opened this issue Aug 7, 2024 · 5 comments
Closed

Default Media Type application/xml is selected by default #2671

x-carrier opened this issue Aug 7, 2024 · 5 comments

Comments

@x-carrier
Copy link

Describe the bug
I wrote an interface,produces = {"application/json", "application/xml"}, consumes = {"application/json", "application/xml"}
image
When the springdoc version was 2.5.0, application/json was selected by default
image
image
But when I switched to 2.6.0, the default choice changed to application/xml
image
image
I haven't changed anything except the version number of springdoc and I would like to know how to configure the Media type to return to the default application/json value

@limehee
Copy link
Contributor

limehee commented Aug 7, 2024

When referring to the 5.1. springdoc-openapi core properties section, you can change the media type using springdoc.default-consumes-media-type and springdoc.default-produces-media-type.

Please add the following settings to see if they resolve the issue:

If you use properties, add:

springdoc.default-consumes-media-type=application/json
springdoc.default-produces-media-type=application/json

If you use yaml, add:

springdoc:
  default-consumes-media-type: application/json
  default-produces-media-type: application/json

Can you check if the same issue persists after adding these settings?

@x-carrier
Copy link
Author

When referring to the 5.1. springdoc-openapi core properties section, you can change the media type using springdoc.default-consumes-media-type and springdoc.default-produces-media-type.

Please add the following settings to see if they resolve the issue:

springdoc.default-consumes-media-type=application/json
springdoc.default-produces-media-type=application/json
springdoc:
  default-consumes-media-type: application/json
  default-produces-media-type: application/json

Can you check if the same issue persists after adding these settings?
Yes, I added the configuration, changed it to version 2.6.0, and forced the browser to clear the cache refresh, but the result was still application/xml selected by default
image
image
And when I rolled back to version 2.5.0, I reverted back to the default selection of application/json

@limehee
Copy link
Contributor

limehee commented Aug 8, 2024

@bnasslahsen I have identified the issue and submitted a PR to fix it. The problem with the media type order not being preserved, causing the default type not to be prioritized, has been addressed by using LinkedHashSet. I would appreciate it if you could review the PR.

#2672

Thank you.

@cmark
Copy link

cmark commented Oct 9, 2024

We ran into this issue just now and are happy to see a resolution for it already merged into main. May I ask what is the next release date for springdoc that contains this fix? Thanks!

@bnasslahsen
Copy link
Contributor

@cmark,

Most probably, after spring-boot 3.4 goes GA: https://calendar.spring.io/

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

No branches or pull requests

4 participants