refactor: add an overloaded method for resolving required so that the field type can be utilized - #5042
Merged
daniel-kmiecik merged 1 commit intoJan 27, 2026
Conversation
Mattias-Sehlstedt
force-pushed
the
overloaded-required-mode-resolver
branch
2 times, most recently
from
January 26, 2026 17:04
98cd57a to
e88d9de
Compare
Mattias-Sehlstedt
force-pushed
the
overloaded-required-mode-resolver
branch
from
January 26, 2026 19:39
e88d9de to
2cbe66b
Compare
…trivial to base it upon the field type
Mattias-Sehlstedt
force-pushed
the
overloaded-required-mode-resolver
branch
from
January 26, 2026 19:40
2cbe66b to
2831ab4
Compare
daniel-kmiecik
approved these changes
Jan 27, 2026
Collaborator
|
@Mattias-Sehlstedt great work. Thank you for your contribution! |
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Thank you for contributing to swagger-core!
Please fill out the following information to help us review your PR efficiently.
Description
TL;DR:
Makes it possible to easily determine the required mode for a property based upon the class type. This is done by introducing an overloaded method
resolveRequiredModethat also takes aJavaType, and then making the default behavior that the application passes the already accessiblepropTypeto the method.This is a subject I have been asked about before both in swagger-core but also in springdoc-openapi.
There exists good documentation for how to achieve the change for the default for all (define a new
ModelResolverand override theresolveRequiredModemetod). But if we wanted to control it based upon the field/property type, we would have to override the entireModelResolverand its 1000+ linesresolve-method.With this change we can rather go back to only overriding a small, clearly defined, part of the class to achieve the behavior. I have illustrated how this can be achieved in a test.
Type of Change
Checklist
Screenshots / Additional Context