springdoc / springdoc-openapi

Library for OpenAPI 3 with spring-boot
https://springdoc.org
Apache License 2.0
3.26k stars 493 forks source link

Ensure default media type order is preserved using LinkedHashSet in mergeArrays. Fixes #2671 #2672

Closed limehee closed 2 weeks ago

limehee commented 1 month ago

2671 - Ensure default media type order is preserved using LinkedHashSet in mergeArrays

Description

This PR addresses issue #2671 by ensuring that the order of media types is preserved in the mergeArrays method of the MethodAttributes class. Previously, HashSet was used, which did not guarantee the order of media types, causing the default media type not to be prioritized. This has been fixed by using LinkedHashSet to maintain the insertion order.

Changes

Testing

Added the following tests to MethodAttributesTest to ensure the functionality:

Please review the changes and let me know if any further adjustments are needed.

Thank you!