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

Spring 5 support #1773

Closed
pabl0rg opened this Issue Apr 16, 2017 · 85 comments

Comments

Projects
None yet
@pabl0rg

pabl0rg commented Apr 16, 2017

Or are there plans to support it?

@dilipkrish dilipkrish added the feature label Apr 19, 2017

@dilipkrish

This comment has been minimized.

Show comment
Hide comment
@dilipkrish

dilipkrish Apr 19, 2017

Member

There definite is a plan to support it. It will however have to wait till Open API support is completed.

Member

dilipkrish commented Apr 19, 2017

There definite is a plan to support it. It will however have to wait till Open API support is completed.

@oleg-savko

This comment has been minimized.

Show comment
Hide comment
@oleg-savko

oleg-savko Oct 3, 2017

Spring 5 was released. Do u have any progress?

oleg-savko commented Oct 3, 2017

Spring 5 was released. Do u have any progress?

@dilipkrish

This comment has been minimized.

Show comment
Hide comment
@dilipkrish

dilipkrish Oct 4, 2017

Member

@oleg-savko Unfortunately now. Would love some help on this one. Anyone wanting to help with that.

Member

dilipkrish commented Oct 4, 2017

@oleg-savko Unfortunately now. Would love some help on this one. Anyone wanting to help with that.

@amitsaluja

This comment has been minimized.

Show comment
Hide comment
@amitsaluja

amitsaluja Oct 5, 2017

@dilipkrish - Would like to contribute to #1773,can you help me with getting started guide.

amitsaluja commented Oct 5, 2017

@dilipkrish - Would like to contribute to #1773,can you help me with getting started guide.

@dilipkrish

This comment has been minimized.

Show comment
Hide comment
@dilipkrish

dilipkrish Oct 5, 2017

Member

@amitsaluja frankly I haven't tried it andI don't know what it will take. I suspect certain functionality is not working or is broken.

  • Start a project with spring 5
  • See what is broken
  • Come up with a solution and propose a pull request
  • If it looks good and has tests to accompany it, i'll pull it in.

Thank you for wanting to help!

Member

dilipkrish commented Oct 5, 2017

@amitsaluja frankly I haven't tried it andI don't know what it will take. I suspect certain functionality is not working or is broken.

  • Start a project with spring 5
  • See what is broken
  • Come up with a solution and propose a pull request
  • If it looks good and has tests to accompany it, i'll pull it in.

Thank you for wanting to help!

@xBATx

This comment has been minimized.

Show comment
Hide comment
@xBATx

xBATx Oct 5, 2017

Hi @dilipkrish
I looked into it and I found out that there is a lot of job to do.
In webflux, there is no more package web.servlet but it changed to web.reactive which requires more changes than expected. If you want to support the older versions of Spring after release, you probably need to create new modules for webflux where new things will be done.
At the moment, there is 2 modules in the project which are dependent on springframework.web.servlet and directly use a lot of classes from it. Spring 5 has moved staff from there to org.springframework.web.reactive where also some structure and implementation of classes was changed.
Maybe it will be good to figure out how new modules would be organized in the future so the project will be easily maitained. What do you suggest?

xBATx commented Oct 5, 2017

Hi @dilipkrish
I looked into it and I found out that there is a lot of job to do.
In webflux, there is no more package web.servlet but it changed to web.reactive which requires more changes than expected. If you want to support the older versions of Spring after release, you probably need to create new modules for webflux where new things will be done.
At the moment, there is 2 modules in the project which are dependent on springframework.web.servlet and directly use a lot of classes from it. Spring 5 has moved staff from there to org.springframework.web.reactive where also some structure and implementation of classes was changed.
Maybe it will be good to figure out how new modules would be organized in the future so the project will be easily maitained. What do you suggest?

@MinosPong

This comment has been minimized.

Show comment
Hide comment
@MinosPong

MinosPong Oct 25, 2017

Contributor

Hi @dilipkrish, I think the WebFlux support will be a very important milestone for springfox.
Follow with the finding from @xBATx , I would find there are 2 major update on springfox need your input.

  1. Dependency on "org.springframework.web.servlet.mvc" in RequestHandler.
  2. Module layout for webflex support

For (1), currently, RequestHandler depends on class NameValueExpression, PatternsRequestCondition and RequestMappingInfo is in webmvc package. They have the counter part in webflux "org.springframework.web.reactive" (see the link). Shall we consider.

  • define a interface in springfox and adapt the webmvc and webflux class, or
  • adapter the weblux model to webmvc model and not changing RequestHandler.
    For (2), my suggestion is to divide the model springfox-spring-web into springfox-spring-web-common, springfox-spring-webmvc, and springfox-spring-webflux for common class, webmvc and webflux support.
Contributor

MinosPong commented Oct 25, 2017

Hi @dilipkrish, I think the WebFlux support will be a very important milestone for springfox.
Follow with the finding from @xBATx , I would find there are 2 major update on springfox need your input.

  1. Dependency on "org.springframework.web.servlet.mvc" in RequestHandler.
  2. Module layout for webflex support

For (1), currently, RequestHandler depends on class NameValueExpression, PatternsRequestCondition and RequestMappingInfo is in webmvc package. They have the counter part in webflux "org.springframework.web.reactive" (see the link). Shall we consider.

  • define a interface in springfox and adapt the webmvc and webflux class, or
  • adapter the weblux model to webmvc model and not changing RequestHandler.
    For (2), my suggestion is to divide the model springfox-spring-web into springfox-spring-web-common, springfox-spring-webmvc, and springfox-spring-webflux for common class, webmvc and webflux support.
@dilipkrish

This comment has been minimized.

Show comment
Hide comment
@dilipkrish

dilipkrish Oct 26, 2017

Member

@MinosPong thanks for your detailed analysis. I would agree with your findings. I really don't have the bandwidth to work on this right now and could use some help.

Member

dilipkrish commented Oct 26, 2017

@MinosPong thanks for your detailed analysis. I would agree with your findings. I really don't have the bandwidth to work on this right now and could use some help.

@JackFish

This comment has been minimized.

Show comment
Hide comment
@JackFish

JackFish Nov 9, 2017

swagger+netty server+webflux with kotlin is so cool.

JackFish commented Nov 9, 2017

swagger+netty server+webflux with kotlin is so cool.

@dilipkrish

This comment has been minimized.

Show comment
Hide comment
@dilipkrish

dilipkrish Nov 13, 2017

Member

@JackFish baby steps :)

Member

dilipkrish commented Nov 13, 2017

@JackFish baby steps :)

@deblockt

This comment has been minimized.

Show comment
Hide comment
@deblockt

deblockt Jan 17, 2018

Contributor

Hello, I need this feature on my project.
I have rewrite some code of springfox to work exclusively with spring-webflux, this take 4 hours to do.
This work fine, there are two many dependency to broke :

  • spring webmvc
  • servlet-api

Now, I will try to rewrite my code to work with springmvc and spring-webflux in parallel. My big issue is that springfox-core depend of spring-webmvc, I think broke this dependency can broke some dependent projects.

Has someone already start a fork of springfox to work on that?

Contributor

deblockt commented Jan 17, 2018

Hello, I need this feature on my project.
I have rewrite some code of springfox to work exclusively with spring-webflux, this take 4 hours to do.
This work fine, there are two many dependency to broke :

  • spring webmvc
  • servlet-api

Now, I will try to rewrite my code to work with springmvc and spring-webflux in parallel. My big issue is that springfox-core depend of spring-webmvc, I think broke this dependency can broke some dependent projects.

Has someone already start a fork of springfox to work on that?

@deblockt

This comment has been minimized.

Show comment
Hide comment
@deblockt

deblockt Jan 24, 2018

Contributor

I have a verry first working swagger lib on this fork : https://github.com/deblockt/springfox

Is there anyone to work with me on this?

Contributor

deblockt commented Jan 24, 2018

I have a verry first working swagger lib on this fork : https://github.com/deblockt/springfox

Is there anyone to work with me on this?

@goodlifeinc

This comment has been minimized.

Show comment
Hide comment
@goodlifeinc

goodlifeinc Jan 26, 2018

Hi, I checked out your project and managed to adopt it in one of my projects, currently migrated to spring-boot-2.0.0.M7.

Few things I noticed right away though,

  1. I used to have redirect to swagger-ui.html from /, now it says that this redirect cannot be resolved to view, which probably means its not registered since webflux isnt using webmvc.
  2. The Docket is always sending the requests to localhost:8080 even though the app is working on different port, so I will check this out. Managed to define .host() in my Docket to overcome this for now.
  3. I have custom Securities set for different Dockets and even though I authenticate succesfully in swagger the Headers are not being sent, but I think that this is problem of Swagger 2.8 not this project explicitly. (to note I was previously using 2.7, never migrated to 2.8)

goodlifeinc commented Jan 26, 2018

Hi, I checked out your project and managed to adopt it in one of my projects, currently migrated to spring-boot-2.0.0.M7.

Few things I noticed right away though,

  1. I used to have redirect to swagger-ui.html from /, now it says that this redirect cannot be resolved to view, which probably means its not registered since webflux isnt using webmvc.
  2. The Docket is always sending the requests to localhost:8080 even though the app is working on different port, so I will check this out. Managed to define .host() in my Docket to overcome this for now.
  3. I have custom Securities set for different Dockets and even though I authenticate succesfully in swagger the Headers are not being sent, but I think that this is problem of Swagger 2.8 not this project explicitly. (to note I was previously using 2.7, never migrated to 2.8)
@dilipkrish

This comment has been minimized.

Show comment
Hide comment
@dilipkrish

dilipkrish Jan 30, 2018

Member

@deblockt that is really cool!! Would love to help and answer any questions you might have. Let me know if you'd like access to this repo work on it.

Member

dilipkrish commented Jan 30, 2018

@deblockt that is really cool!! Would love to help and answer any questions you might have. Let me know if you'd like access to this repo work on it.

@anagypitech

This comment has been minimized.

Show comment
Hide comment
@anagypitech

anagypitech Feb 6, 2018

@deblockt nice work!
Your changes are working very well with webflux. I hope that it will be in a released version soon.

anagypitech commented Feb 6, 2018

@deblockt nice work!
Your changes are working very well with webflux. I hope that it will be in a released version soon.

@dilipkrish

This comment has been minimized.

Show comment
Hide comment
@dilipkrish

dilipkrish Feb 6, 2018

Member

@deblockt Would you like to send a PR to pull your changes in.

Member

dilipkrish commented Feb 6, 2018

@deblockt Would you like to send a PR to pull your changes in.

@ligasgr ligasgr referenced this issue Aug 9, 2018

Merged

Feature/webflux #2608

dilipkrish added a commit that referenced this issue Aug 18, 2018

@dilipkrish

This comment has been minimized.

Show comment
Hide comment
@dilipkrish

dilipkrish Aug 18, 2018

Member

Big thank you to @deblockt and @ligasgr! This has been merged, would appreciate any/all feedback for 3.0.0-SNAPSHOT!

Member

dilipkrish commented Aug 18, 2018

Big thank you to @deblockt and @ligasgr! This has been merged, would appreciate any/all feedback for 3.0.0-SNAPSHOT!

@clebettre

This comment has been minimized.

Show comment
Hide comment
@clebettre

clebettre Aug 18, 2018

@dilipkrish I just try to use sprinfox / spring-fox-swagger-ui 3.0.0-SNAPSHOT with Spring 5 + Spring WebFlux, and it works like a charm.

Thank you for your great work !
And thank you to all contributors of this feature !

clebettre commented Aug 18, 2018

@dilipkrish I just try to use sprinfox / spring-fox-swagger-ui 3.0.0-SNAPSHOT with Spring 5 + Spring WebFlux, and it works like a charm.

Thank you for your great work !
And thank you to all contributors of this feature !

@pgilad

This comment has been minimized.

Show comment
Hide comment
@pgilad

pgilad Aug 19, 2018

@clebettre I couldn't get it to work with Webflux, can you give an example minimal working project with swagger2 and webflux?

pgilad commented Aug 19, 2018

@clebettre I couldn't get it to work with Webflux, can you give an example minimal working project with swagger2 and webflux?

@ligasgr

This comment has been minimized.

Show comment
Hide comment
@ligasgr

ligasgr Aug 19, 2018

Contributor

@pgilad
Please make sure that as mentioned in #2608 you have to have

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>3.0.0-SNAPSHOT</version>
</dependency>

and

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-spring-webflux</artifactId>
    <version>3.0.0-SNAPSHOT</version>
</dependency>
Contributor

ligasgr commented Aug 19, 2018

@pgilad
Please make sure that as mentioned in #2608 you have to have

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>3.0.0-SNAPSHOT</version>
</dependency>

and

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-spring-webflux</artifactId>
    <version>3.0.0-SNAPSHOT</version>
</dependency>
@clebettre

This comment has been minimized.

Show comment
Hide comment
@clebettre

clebettre Aug 19, 2018

@pgilad If you need an example, see this repository : https://github.com/clebettre/springfox-spring-webflux-example

<dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>3.0.0-SNAPSHOT</version>
        </dependency>
  • You also need to use the annotation @EnableSwagger2WebFlux on your SpringApplication.class (or on your configuration class)

Hope this helps

clebettre commented Aug 19, 2018

@pgilad If you need an example, see this repository : https://github.com/clebettre/springfox-spring-webflux-example

<dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>3.0.0-SNAPSHOT</version>
        </dependency>
  • You also need to use the annotation @EnableSwagger2WebFlux on your SpringApplication.class (or on your configuration class)

Hope this helps

@pgilad

This comment has been minimized.

Show comment
Hide comment
@pgilad

pgilad Aug 19, 2018

Thanks that is awesome!

pgilad commented Aug 19, 2018

Thanks that is awesome!

@goodlifeinc

This comment has been minimized.

Show comment
Hide comment
@goodlifeinc

goodlifeinc Aug 20, 2018

Hi guys,

The new 3.0.0 snapshot is working great, I have even tried it with older version of swagger-ui - 2.7.0 and its perfect.

One thing I notice though, in Swagger2ControllerWebFlux there is

private static final String DEFAULT_URL = "/v2/api-docs";

And on the getDocumentation() method:

@RequestMapping(
  value = DEFAULT_URL,
  method = RequestMethod.GET,
  produces = { APPLICATION_JSON_VALUE, HAL_MEDIA_TYPE })

which gives us no way of overwriting the documentation path with springfox.documentation.swagger.v2.path in application.properties.

goodlifeinc commented Aug 20, 2018

Hi guys,

The new 3.0.0 snapshot is working great, I have even tried it with older version of swagger-ui - 2.7.0 and its perfect.

One thing I notice though, in Swagger2ControllerWebFlux there is

private static final String DEFAULT_URL = "/v2/api-docs";

And on the getDocumentation() method:

@RequestMapping(
  value = DEFAULT_URL,
  method = RequestMethod.GET,
  produces = { APPLICATION_JSON_VALUE, HAL_MEDIA_TYPE })

which gives us no way of overwriting the documentation path with springfox.documentation.swagger.v2.path in application.properties.

@eximius313

This comment has been minimized.

Show comment
Hide comment
@eximius313

eximius313 Aug 21, 2018

I was trying to use 3.0.0-SNAPSHOT, but I get java.lang.ClassCastException: springfox.documentation.builders.PathSelectors$1 cannot be cast to com.google.common.base.Predicate

Previously this worked like that:

@Bean
public Docket api(final TypeResolver typeResolver) {
        return new Docket(DocumentationType.SWAGGER_2)
            .groupName("BitBay Pay")
            .apiInfo(apiInfo())
            .select()
            .paths(Predicates.not((Predicate<String>)PathSelectors.regex("/actuator.*"))) <-- here
            .build()
            .genericModelSubstitutes(Mono.class)
            .alternateTypeRules(
                AlternateTypeRules.newRule(
                    typeResolver.resolve(Flux.class, WildcardType.class),
                    typeResolver.resolve(Collection.class, WildcardType.class)))
            .useDefaultResponseMessages(false);
    }

How do I define regexp predicate now?

eximius313 commented Aug 21, 2018

I was trying to use 3.0.0-SNAPSHOT, but I get java.lang.ClassCastException: springfox.documentation.builders.PathSelectors$1 cannot be cast to com.google.common.base.Predicate

Previously this worked like that:

@Bean
public Docket api(final TypeResolver typeResolver) {
        return new Docket(DocumentationType.SWAGGER_2)
            .groupName("BitBay Pay")
            .apiInfo(apiInfo())
            .select()
            .paths(Predicates.not((Predicate<String>)PathSelectors.regex("/actuator.*"))) <-- here
            .build()
            .genericModelSubstitutes(Mono.class)
            .alternateTypeRules(
                AlternateTypeRules.newRule(
                    typeResolver.resolve(Flux.class, WildcardType.class),
                    typeResolver.resolve(Collection.class, WildcardType.class)))
            .useDefaultResponseMessages(false);
    }

How do I define regexp predicate now?

@IsaacDeLaRosa

This comment has been minimized.

Show comment
Hide comment
@IsaacDeLaRosa

IsaacDeLaRosa Aug 22, 2018

Hi! thank you so much for supporting webflux!
I am trying to auto generate reactive/reactor classes using springfox.
I added the required dependencies and the @EnableSwagger2WebFlux to my empty Configuration class. how and where can I define if the auto gen controller will be a Mono or Flux for example? because right now its neither of them.

IsaacDeLaRosa commented Aug 22, 2018

Hi! thank you so much for supporting webflux!
I am trying to auto generate reactive/reactor classes using springfox.
I added the required dependencies and the @EnableSwagger2WebFlux to my empty Configuration class. how and where can I define if the auto gen controller will be a Mono or Flux for example? because right now its neither of them.

@cbornet

This comment has been minimized.

Show comment
Hide comment
@cbornet

cbornet Aug 22, 2018

Contributor

Springfox works in the opposite direction : it generates OAI specs from your Webflux endpoints. To generate code from an OAI spec, use something like OpenAPI-generator

Contributor

cbornet commented Aug 22, 2018

Springfox works in the opposite direction : it generates OAI specs from your Webflux endpoints. To generate code from an OAI spec, use something like OpenAPI-generator

@dilipkrish

This comment has been minimized.

Show comment
Hide comment
@dilipkrish

dilipkrish Aug 26, 2018

Member

which gives us no way of overwriting the documentation path with springfox.documentation.swagger.v2.path in application.properties.

@goodlifeinc thats great feedback, as you notice the 3.0.0-SNAPSHOT is still a little rough.

I was trying to use 3.0.0-SNAPSHOT, but I get java.lang.ClassCastException: springfox.documentation.builders.PathSelectors$1 cannot be cast to com.google.common.base.Predicate

@eximius313 Try switching to using standard java predicates. We removed the guava dependency from the library.

@IsaacDeLaRosa would appreciate taking the discussion of open api generator to the respective repository.

Member

dilipkrish commented Aug 26, 2018

which gives us no way of overwriting the documentation path with springfox.documentation.swagger.v2.path in application.properties.

@goodlifeinc thats great feedback, as you notice the 3.0.0-SNAPSHOT is still a little rough.

I was trying to use 3.0.0-SNAPSHOT, but I get java.lang.ClassCastException: springfox.documentation.builders.PathSelectors$1 cannot be cast to com.google.common.base.Predicate

@eximius313 Try switching to using standard java predicates. We removed the guava dependency from the library.

@IsaacDeLaRosa would appreciate taking the discussion of open api generator to the respective repository.

@mikezerosix

This comment has been minimized.

Show comment
Hide comment
@mikezerosix

mikezerosix Aug 27, 2018

With latest Spring boot & data REST I am getting:

No qualifying bean of type 'com.fasterxml.classmate.TypeResolver' available

springfox-data-rest-3.0.0-20180818.144717-9.jar!/springfox/documentation/spring/data/rest/EntityServicesProvider.class]: Unsatisfied dependency expressed through constructor parameter 4; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.fasterxml.classmate.TypeResolver' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

This might be jackson (databind) version conflict in Spring boot and swagger ?

mikezerosix commented Aug 27, 2018

With latest Spring boot & data REST I am getting:

No qualifying bean of type 'com.fasterxml.classmate.TypeResolver' available

springfox-data-rest-3.0.0-20180818.144717-9.jar!/springfox/documentation/spring/data/rest/EntityServicesProvider.class]: Unsatisfied dependency expressed through constructor parameter 4; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.fasterxml.classmate.TypeResolver' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

This might be jackson (databind) version conflict in Spring boot and swagger ?

@drenda

This comment has been minimized.

Show comment
Hide comment
@drenda

drenda Aug 27, 2018

Sorry if I update this tthinked but probably is related to this topic. I'm using the last snapshot and I've and endpoint like this:

@GetMapping(path = "/loggedAgent")
	public ResponseEntity<?> loggedAgent(Locale locale, PersistentEntityResourceAssembler resourceAssembler) {
		CustomUserDetail loggedUser = SecurityUtils.getLoggedUser();
		Agent loggedAgent = agentRepository.findByUsername(loggedUser.getUsername());

		if (loggedAgent != null)
			return new ResponseEntity<>(resourceAssembler.toResource(loggedAgent), HttpStatus.OK);
		throw new ResourceNotFoundException(ExceptionCode.RESOURCE_NOT_FOUND, "");
	}

In my application I'm using Spring (Spring MVC, Spring Data REST); localeand resourceAssembler are two parameters injected by Spring and they should not be displayed in Swagger.

Instead I see this.

error

If the method has some real addition parameter, then localeand resourceAssembler are not displayed anymore.

Is that a desidered behaviour?

Thanks

drenda commented Aug 27, 2018

Sorry if I update this tthinked but probably is related to this topic. I'm using the last snapshot and I've and endpoint like this:

@GetMapping(path = "/loggedAgent")
	public ResponseEntity<?> loggedAgent(Locale locale, PersistentEntityResourceAssembler resourceAssembler) {
		CustomUserDetail loggedUser = SecurityUtils.getLoggedUser();
		Agent loggedAgent = agentRepository.findByUsername(loggedUser.getUsername());

		if (loggedAgent != null)
			return new ResponseEntity<>(resourceAssembler.toResource(loggedAgent), HttpStatus.OK);
		throw new ResourceNotFoundException(ExceptionCode.RESOURCE_NOT_FOUND, "");
	}

In my application I'm using Spring (Spring MVC, Spring Data REST); localeand resourceAssembler are two parameters injected by Spring and they should not be displayed in Swagger.

Instead I see this.

error

If the method has some real addition parameter, then localeand resourceAssembler are not displayed anymore.

Is that a desidered behaviour?

Thanks

@eximius313

This comment has been minimized.

Show comment
Hide comment
@eximius313

eximius313 Aug 27, 2018

We also observed that version 3.0.0-SNAPSHOT caused some arguments (that were previously hidden) to appear (e.g. ServerWebExchange, AuthenticationPrincipal).
We solved this by adding .ignoredParameterTypes(AuthenticationPrincipal.class, ServerWebExchange.class) to our Docket

eximius313 commented Aug 27, 2018

We also observed that version 3.0.0-SNAPSHOT caused some arguments (that were previously hidden) to appear (e.g. ServerWebExchange, AuthenticationPrincipal).
We solved this by adding .ignoredParameterTypes(AuthenticationPrincipal.class, ServerWebExchange.class) to our Docket

@drenda

This comment has been minimized.

Show comment
Hide comment
@drenda

drenda Aug 27, 2018

@eximius313 Thanks. Useful hint. @dilipkrish can you confirm this is a desired behaviour and we have to hide them programatically? Thanks

drenda commented Aug 27, 2018

@eximius313 Thanks. Useful hint. @dilipkrish can you confirm this is a desired behaviour and we have to hide them programatically? Thanks

@dilipkrish

This comment has been minimized.

Show comment
Hide comment
@dilipkrish

dilipkrish Aug 28, 2018

Member

@dilipkrish can you confirm this is a desired behaviour and we have to hide them programatically?

This is good feedback. It is not the expected, this is obviously the result of not accounting for spring 5.0 types. Would you be kind enough to create an issue for that so that it can be tracked.

Member

dilipkrish commented Aug 28, 2018

@dilipkrish can you confirm this is a desired behaviour and we have to hide them programatically?

This is good feedback. It is not the expected, this is obviously the result of not accounting for spring 5.0 types. Would you be kind enough to create an issue for that so that it can be tracked.

@drenda

This comment has been minimized.

Show comment
Hide comment
@drenda

drenda commented Aug 28, 2018

@dilipkrish Created #2642

Thanks

wlanboy added a commit to wlanboy/CrudService that referenced this issue Aug 29, 2018

wlanboy added a commit to wlanboy/CrudService that referenced this issue Aug 31, 2018

Springboot20 (#1)
* Update pom for Spring Boot Version 2.0.4

* Update for method name change from findOne to findById of Spring Data Repository.

* Update for Lombok enhancement

* Update for Lombok integration

* Removed Swagger because of springfox/springfox#1773

* Update on classpath

* Added Build Info
@mpanicker

This comment has been minimized.

Show comment
Hide comment
@mpanicker

mpanicker Sep 10, 2018

I am trying to use the github example project from clebettre (https://github.com/clebettre/springfox-spring-webflux-example)

and i am getting Caused by: java.io.FileNotFoundException: class path resource [springfox/documentation/spring/web/SpringfoxWebFluxConfiguration.class] cannot be opened because it does not exist

Any idea what the issue is?

mpanicker commented Sep 10, 2018

I am trying to use the github example project from clebettre (https://github.com/clebettre/springfox-spring-webflux-example)

and i am getting Caused by: java.io.FileNotFoundException: class path resource [springfox/documentation/spring/web/SpringfoxWebFluxConfiguration.class] cannot be opened because it does not exist

Any idea what the issue is?

@mpanicker

This comment has been minimized.

Show comment
Hide comment
@mpanicker

mpanicker Sep 10, 2018

I figured it out. I had to create

@Configuration
public class WebFluxConfig implements WebFluxConfigurer {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        //swagger resource
        //registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        registry.addResourceHandler("/swagger/**").addResourceLocations("classpath:/static/swagger/");
    }
}

After that i could see all endpoints except the swagger-ui.html(got 404 error). I wrestled with this problem for a long time. Finally by trial and error, I commented out the swagger-ui.html mapping and it workled

mpanicker commented Sep 10, 2018

I figured it out. I had to create

@Configuration
public class WebFluxConfig implements WebFluxConfigurer {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        //swagger resource
        //registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        registry.addResourceHandler("/swagger/**").addResourceLocations("classpath:/static/swagger/");
    }
}

After that i could see all endpoints except the swagger-ui.html(got 404 error). I wrestled with this problem for a long time. Finally by trial and error, I commented out the swagger-ui.html mapping and it workled

@pgilad

This comment has been minimized.

Show comment
Hide comment
@pgilad

pgilad Sep 11, 2018

I put together a basic starter demo repo (Gradle+Java) that has a minimal working example of Webflux + Swagger2. Currently I used @mpanicker work-around to get swagger-ui.html path to work (otherwise I get 404s).

https://github.com/pgilad/spring-boot-webflux-swagger-starter

pgilad commented Sep 11, 2018

I put together a basic starter demo repo (Gradle+Java) that has a minimal working example of Webflux + Swagger2. Currently I used @mpanicker work-around to get swagger-ui.html path to work (otherwise I get 404s).

https://github.com/pgilad/spring-boot-webflux-swagger-starter

@sumitramteke

This comment has been minimized.

Show comment
Hide comment
@sumitramteke

sumitramteke Sep 14, 2018

For those who don't know, to import snapshots Springfox has provided steps.

<repositories>
    <repository>
      <id>jcenter-snapshots</id>
      <name>jcenter</name>
      <url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
    </repository>
</repositories>

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-spring-webflux</artifactId>
    <version>3.0.0-SNAPSHOT</version>
</dependency>

sumitramteke commented Sep 14, 2018

For those who don't know, to import snapshots Springfox has provided steps.

<repositories>
    <repository>
      <id>jcenter-snapshots</id>
      <name>jcenter</name>
      <url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
    </repository>
</repositories>

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-spring-webflux</artifactId>
    <version>3.0.0-SNAPSHOT</version>
</dependency>
@kimec

This comment has been minimized.

Show comment
Hide comment
@kimec

kimec Sep 17, 2018

Just for clarification, as @mirromutth has pointed out initially, it seems that Spring Fox WebFlux support in its current form, does not work with the new WebFlux RouterFunction<ServerResponse> API. By that I mean WebFlux in controller-less setup without any MVC annotations whatsoever.

This was brought up by @ianhitlgang in #2416 also.

Are there any plans to provide some semi automated solution for this or maybe some workaround along the lines of an older discussion in #1216?

EDIT:
As a workaround for controller-less WebFlux applications, you can write ApiListingScannerPlugin implementation and register types and endpoints manually. Good discussion on how to register and reference model types is in #1509.

kimec commented Sep 17, 2018

Just for clarification, as @mirromutth has pointed out initially, it seems that Spring Fox WebFlux support in its current form, does not work with the new WebFlux RouterFunction<ServerResponse> API. By that I mean WebFlux in controller-less setup without any MVC annotations whatsoever.

This was brought up by @ianhitlgang in #2416 also.

Are there any plans to provide some semi automated solution for this or maybe some workaround along the lines of an older discussion in #1216?

EDIT:
As a workaround for controller-less WebFlux applications, you can write ApiListingScannerPlugin implementation and register types and endpoints manually. Good discussion on how to register and reference model types is in #1509.

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