springdoc-openapi icon indicating copy to clipboard operation
springdoc-openapi copied to clipboard

Default Media Type application/xml is selected by default

Open x-carrier opened this issue 1 year ago • 3 comments

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

x-carrier avatar Aug 07 '24 05:08 x-carrier

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?

limehee avatar Aug 07 '24 06:08 limehee

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

x-carrier avatar Aug 07 '24 06:08 x-carrier

@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.

limehee avatar Aug 08 '24 03:08 limehee

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!

cmark avatar Oct 09 '24 16:10 cmark

@cmark,

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

bnasslahsen avatar Oct 09 '24 17:10 bnasslahsen