feat: change Schema.required from List to Set (#5027)#5037
feat: change Schema.required from List to Set (#5027)#5037yht0827 wants to merge 1 commit intoswagger-api:masterfrom
Conversation
073befa to
88e6aab
Compare
|
Hi @yht0827,
They also differ in how they treat empty/null:
|
88e6aab to
74b6c87
Compare
- Change internal storage from List<String> to Set<String> using TreeSet - Keep public API compatible (getRequired() returns a defensive copy as List<String>) - Make addRequiredItem() consistent with setRequired(): ignore items not present in properties - Add JavaDoc to getRequired() explaining the defensive copy behavior - Add unit tests for duplicate handling, sorting, and consisteny
ff8fc26 to
d9cf8b5
Compare
|
Hi @ewaostrowska, thank you for the detailed review! I've addressed all the feedback:
Please take another look when you have a chance. Thank you! |
|
@yht0827 thank you for the contribution. However, this PR introduces two silent breaking changes that we'd like to avoid outside of a major release:
Since we're not planning a new major release in the near term, we've prepared a non-breaking alternative in #5163 that achieves the same deduplication goal by keeping List internally and adding contains() guards in addRequiredItem(), setRequired(), and the required(List) builder (zero API impact, no behavioral regression for existing callers). Your work was a great starting point and helped us identify and reason through the problem clearly. We really appreciate the effort you put into this. If you feel the SortedSet-based approach is still worth pursuing for a future major release, feel free to leave this PR open. Otherwise, feel free to close it. |
|
Thank you for the thorough explanation, @daniel-kmiecik. I'll close this PR since the team has a non-breaking alternative ready. Happy to have contributed to identifying the problem! |
Pull Request
Thank you for contributing to swagger-core!
Please fill out the following information to help us review your PR efficiently.
Description
Change
Schema.requiredfield type fromList<String>toSet<String>to prevent duplicate required properties.Fixes: #5027
Type of Change
Checklist
Screenshots / Additional Context