Skip to content

fix: make CollectionModelContentConverter conditional on LinkRelationProvider bean - #3365

Open
anupamchaubey wants to merge 2 commits into
springdoc:mainfrom
anupamchaubey:fix-hateoas-linkrelationprovider-conditional
Open

anupamchaubey wants to merge 2 commits into
springdoc:mainfrom
anupamchaubey:fix-hateoas-linkrelationprovider-conditional

Conversation

@anupamchaubey

Copy link
Copy Markdown

Description

SpringDocHateoasConfiguration currently uses @ConditionalOnClass(LinkRelationProvider.class), but the collectionModelContentConverter bean method requires a LinkRelationProvider bean.

When the class is present on the classpath but no bean of that type exists, the application fails to start with:

Changes

  • Added @ConditionalOnBean(LinkRelationProvider.class) to the collectionModelContentConverter method.

This ensures the bean is only created when a LinkRelationProvider is actually available.

Related Issue

Fixes #3364

…Provider bean

Add @ConditionalOnBean(LinkRelationProvider.class) so the configuration
does not fail when the class is present but no bean exists.

Fixes springdoc#3364
@Mattias-Sehlstedt

Copy link
Copy Markdown
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
@anupamchaubey

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SpringDocHateoasConfiguration breaks when there is no LinkRelationProvider bean

2 participants