Skip to content

SpringDocHateoasConfiguration breaks when there is no LinkRelationProvider bean #3364

Description

@breun

Describe the bug

SpringDocHateoasConfiguration assumes a LinkRelationProvider bean can be injected, but doesn't verify that such a bean actually exists.

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?

Spring Boot 4.1.1.

  • What modules and versions of springdoc-openapi are you using?

springdoc-openapi-starter-webmvc-api 3.1.1.

  • What is the actual and the expected result using OpenAPI Description (yml or json)?

Not applicable.

  • Provide with a sample code (HelloController) or Test that reproduces the problem

org.springdoc.core.configuration.SpringDocHateoasConfiguration#collectionModelContentConverter(HateoasHalProvider, LinkRelationProvider) requires a LinkRelationProvider bean. This auto-configuration class verifies that the LinkRelationProvider class is present using @ConditionalOnClass (on multiple levels even, which seems redundant), but it never verifies that a bean of this type is present (using @ConditionalOnBean), so the auto-configuration fails when there is no LinkRelationProvider bean:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'modelConverterRegistrar' defined in class path resource [org/springdoc/core/configuration/SpringDocConfiguration.class]: Unsatisfied dependency expressed through method 'modelConverterRegistrar' parameter 0: Error creating bean with name 'collectionModelContentConverter' defined in class path resource [org/springdoc/core/configuration/SpringDocHateoasConfiguration.class]: Unsatisfied dependency expressed through method 'collectionModelContentConverter' parameter 1: No qualifying bean of type 'org.springframework.hateoas.server.LinkRelationProvider' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

Expected behavior

  • A clear and concise description of what you expected to happen.

I expect SpringDocHateoasConfiguration to not fail when the LinkRelationProvider class is present, but there is no bean of this type.

  • What is the expected result using OpenAPI Description (yml or json)?

Not applicable.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions