Skip to content

No documented way to handle Mono/Flux without Webflux #523

Closed
@pkubowicz

Description

@pkubowicz

Describe the bug

  • If you are reporting a bug, please help to speed up problem diagnosis by providing as much information as possible:
  • A clear and concise description of what the bug is: the title of an issue is not enough

To Reproduce
I have Spring MVC (no spring-webflux) application based on Spring Boot 2.2.6 and Springdoc 1.3.0.

My controllers return Flux and Mono.

By default springdoc's swagger-ui page displays Flux response as:

{
  "prefetch": 0
}

When I include org.springdoc:springdoc-openapi-webflux-core:1.3.0 my application fails to start:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springdoc.core.SpringDocWebMvcConfiguration.openApiResource(SpringDocWebMvcConfiguration.java:60)

The following method did not exist:

    'void org.springdoc.api.OpenApiResource.<init>(java.lang.String, org.springdoc.core.OpenAPIBuilder, org.springdoc.core.AbstractRequestBuilder, org.springdoc.core.GenericResponseBuilder, org.springdoc.core.OperationBuilder, org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping, java.util.Optional, java.util.Optional, org.springdoc.core.SpringDocConfigProperties, java.util.Optional)'

The method's class, org.springdoc.api.OpenApiResource, is available from the following locations:

    jar:file:/home/pkubowicz/.gradle/caches/modules-2/files-2.1/org.springdoc/springdoc-openapi-webflux-core/1.3.0/9254ae87d259128c266dcb64a8fdefefa776fbcb/springdoc-openapi-webflux-core-1.3.0.jar!/org/springdoc/api/OpenApiResource.class
    jar:file:/home/pkubowicz/.gradle/caches/modules-2/files-2.1/org.springdoc/springdoc-openapi-webmvc-core/1.3.0/13bab9bda41e79dbc041c5fb4e564548e7cd0ffd/springdoc-openapi-webmvc-core-1.3.0.jar!/org/springdoc/api/OpenApiResource.class

The work-around is to execute:

SpringDocUtils.getConfig().addResponseWrapperToIgnore(Mono::class.java)
SpringDocUtils.getConfig().addResponseWrapperToIgnore(Flux::class.java)

Expected behavior
This use case should be documented - should springdoc-openapi-webflux-core be used or not used, and if not the documentation should explain how to 'unwrap' Flux and Mono.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions