fix: make CollectionModelContentConverter conditional on LinkRelationProvider bean - #3365
Open
anupamchaubey wants to merge 2 commits into
Open
anupamchaubey wants to merge 2 commits into
anupamchaubey wants to merge 2 commits into
Conversation
…Provider bean Add @ConditionalOnBean(LinkRelationProvider.class) so the configuration does not fail when the class is present but no bean exists. Fixes springdoc#3364
Contributor
|
Could we consider adding/extending the unit-test suite to also cover this case of application context configuration, so that we prevent regressions while also better showing the entire expected "application context suite" that might be used for the application. See for example the test suite that I modified in #3329. |
…Provider bean Add @ConditionalOnBean(LinkRelationProvider.class) via a nested configuration so the converter is only created when the bean exists. Application context no longer fails when the class is present but no bean is available. Also extend the unit tests to cover both presence and absence of the bean. Fixes springdoc#3364
Author
|
Thanks for the feedback. I've added a nested configuration guarded by @ConditionalOnBean(LinkRelationProvider.class) and extended the unit tests to cover both cases (bean present / bean absent). All tests in SpringDocHateoasConfigurationTest are now green. |
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.
Description
SpringDocHateoasConfigurationcurrently uses@ConditionalOnClass(LinkRelationProvider.class), but thecollectionModelContentConverterbean method requires aLinkRelationProviderbean.When the class is present on the classpath but no bean of that type exists, the application fails to start with:
Changes
@ConditionalOnBean(LinkRelationProvider.class)to thecollectionModelContentConvertermethod.This ensures the bean is only created when a
LinkRelationProvideris actually available.Related Issue
Fixes #3364