Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy Initialisation breaks WebFlux support #562

Closed
jonathannaguin opened this issue Apr 13, 2020 · 4 comments
Closed

Lazy Initialisation breaks WebFlux support #562

jonathannaguin opened this issue Apr 13, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@jonathannaguin
Copy link

Describe the bug

  • If the application has spring.application.main.lazy-initialization set to true, then it seems the lib drops support for webFlux responses, Mono or Flux.

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using? Using Spring Boot 2.2.6.RELEASE.
  • What modules and versions of springdoc-openapi are you using? org.springdoc:springdoc-openapi-webflux-ui:1.3.2
  • What is the actual and the expected result using OpenAPI Description (yml or json)? To support Flux or Mono responses.
  • Provide with a sample code (HelloController) or Test that reproduces the problem. A simple controller code like this:
	@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get All Tweets") })
	@GetMapping("/tweets")
	public Flux<TweetDTO> getAllTweets() {
		Flux<Tweet> tweet = tweetRepository.findAll();
		return tweetMapper.toDTO(tweet);
	}

Expected behavior

  • A clear and concise description of what you expected to happen. Regardless of the lazy initialisation setting, the library should behave the same way.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
I tried to debug why this wasn't working and I realized the class WebFluxSupportConverter is not getting invoked at all when the Swagger documentation data gets generated. The bean is created but never invoked.

@bnasslahsen
Copy link
Contributor

@jonathannaguin,

Unable to reproduce. Just tesed on https://github.com/springdoc/springdoc-openapi-demos/tree/master/springdoc-openapi-test-app3.

First of all review your project configuration: This ticket will be closed, and there is no need to reopen a new open for the same issue.

If you are reporting a bug, please help to speed up problem diagnosis by providing as much information as possible: You can update your ticket with the necessary information and it will be reopened.

Please have a look at the contribution guide section Using GitHub Issues:

@jonathannaguin
Copy link
Author

jonathannaguin commented Apr 13, 2020

@bnasslahsen I've just tried with the sample app and the problem is there:

image

image

The only modification I had to make was on the application.yml:

server:
  servlet:
    context-path: /
  compression:
    enabled: true
    mime-types: text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json
    min-response-size: 1024
  http2:
    enabled: true
spring:
  resources:
    cache:
      period: 31536000
      cachecontrol:
        max-age: 31536000
    chain:
      html-application-cache: true
      enabled: true
      strategy:
        content:
          enabled: true
          paths: /webjars/swagger-ui/**.*
  main:
    lazy-initialization: true #### CONFIG ADDED
springdoc:
  version: '@springdoc.version@'

Could you please try it out? I can create a fork of that repo if you want too.

@bnasslahsen
Copy link
Contributor

@jonathannaguin,

In fact, i have tested with your first property spring.application.main.lazy-initialization, in the description.
With your second description with the right property spring.main.lazy-initialization, the issue is reproducible and will be fixed for the next release.

@jonathannaguin
Copy link
Author

Ah! Apologies! Problem with copying/pasting from the YML file.
I really appreciate your help on this.

@bnasslahsen bnasslahsen added the bug Something isn't working label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants