I also have meet this problem.
I used flowable 6.3.1, and swagger 2.8.0
-
Gradle dependencies as following:
dependencies {
compile “org.flowable:flowable-spring-boot-starter-rest:6.3.1”
compile “com.h2database:h2:1.4.197”
compile “io.springfox:springfox-swagger2:2.8.0”
compile “io.springfox:springfox-swagger-ui:2.8.0”
}
-
SpringBootApplication as following:
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication
@EnableSwagger2
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public Docket restfullApi() {
Docket docket = new Docket(DocumentationType.SWAGGER_2);
docket.apiInfo(new ApiInfoBuilder().title("flowable").version("6.3.1").build());
docket.select().apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)).build();
return docket;
}
}
-
I add a RestController for test:
/**
*
*/
package com.example.demo.controller;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
*/
@Api(tags = “Hello World”)
@RestController
public class MyRestController {
@ApiOperation(value = “hello world”)
@GetMapping(value = “/hello/world”)
public ResponseEntity startProcessInstance() {
return new ResponseEntity<>(“hello world”, HttpStatus.OK);
}
}
-
Add following config in application.properties:
flowable.process.servlet.loadOnStartup=1
flowable.app.servlet.loadOnStartup=1
====================================================
After startup the spring boot application, find the rest api in the log:
…
2018-06-08 17:12:52.509 INFO 23992 — [localhost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
…
2018-06-08 17:12:53.342 INFO 23992 — [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped “{[/hello/world],methods=[GET]}” onto public org.springframework.http.ResponseEntity<java.lang.String> com.example.demo.controller.MyRestController.startProcessInstance()
…
2018-06-08 17:12:58.278 INFO 23992 — [main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2018-06-08 17:12:58.296 INFO 23992 — [main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2018-06-08 17:12:58.329 INFO 23992 — [main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2018-06-08 17:12:58.486 INFO 23992 — [main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet ‘Flowable BPMN Rest API’
2018-06-08 17:12:58.486 INFO 23992 — [main] o.s.web.servlet.DispatcherServlet : FrameworkServlet ‘Flowable BPMN Rest API’: initialization started
…
2018-06-08 17:12:59.811 INFO 23992 — [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped “{[/query/historic-detail],methods=[POST],produces=[application/json]}” onto public org.flowable.common.rest.api.DataResponse<org.flowable.rest.service.api.history.HistoricDetailResponse> org.flowable.rest.service.api.history.HistoricDetailQueryResource.queryHistoricDetail(org.flowable.rest.service.api.history.HistoricDetailQueryRequest,java.util.Map<java.lang.String, java.lang.String>,javax.servlet.http.HttpServletRequest)
2018-06-08 17:12:59.813 INFO 23992 — [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped “{[/history/historic-process-instances/{processInstanceId}/comments/{commentId}],methods=[GET],produces=[application/json]}” onto public org.flowable.rest.service.api.engine.CommentResponse org.flowable.rest.service.api.history.HistoricProcessInstanceCommentResource.getComment(java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest)
…
2018-06-08 17:13:00.037 INFO 23992 — [main] o.s.web.servlet.DispatcherServlet : FrameworkServlet ‘Flowable BPMN Rest API’: initialization completed in 1551 ms
2018-06-08 17:13:00.038 INFO 23992 — [main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet ‘Flowable App Rest API’
2018-06-08 17:13:00.038 INFO 23992 — [main] o.s.web.servlet.DispatcherServlet : FrameworkServlet ‘Flowable App Rest API’: initialization started
2018-06-08 17:13:00.038 INFO 23992 — [main] .s.AnnotationConfigWebApplicationContext : Refreshing WebApplicationContext for namespace ‘Flowable App Rest API-servlet’: startup date [Fri Jun 08 17:13:00 CST 2018]; parent: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2f6bbeb0
2018-06-08 17:13:00.039 INFO 23992 — [main] .s.AnnotationConfigWebApplicationContext : Registering annotated classes: [class org.flowable.spring.boot.app.AppEngineRestConfiguration]
2018-06-08 17:13:00.141 INFO 23992 — [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped “{[/app-repository/deployments/{deploymentId}/resources],methods=[GET],produces=[application/json]}” onto public java.util.List<org.flowable.app.rest.service.api.repository.AppDeploymentResourceResponse> org.flowable.app.rest.service.api.repository.AppDeploymentResourceCollectionResource.getDeploymentResources(java.lang.String,javax.servlet.http.HttpServletRequest)
…
2018-06-08 17:13:00.217 INFO 23992 — [main] o.s.web.servlet.DispatcherServlet : FrameworkServlet ‘Flowable App Rest API’: initialization completed in 179 ms
2018-06-08 17:13:00.219 INFO 23992 — [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ‘’
2018-06-08 17:13:00.221 INFO 23992 — [main] com.example.demo.Application : Started Application in 10.332 seconds (JVM running for 11.337)
but when I browse http://127.0.0.1:8080/swagger-ui.html, only display /hello/world api.
Flowable BPMN Rest API and Flowable App Rest API are not display.
The reason is /hello/world, Flowable BPMN Rest API and Flowable App Rest API are in different WebApplicationContext, and swagger configuration only scaned the ApiOperation which in a same WebApplicationContext whit DocumentationPluginsBootstrapper bean.
I want to know, how to config swagger to scan the WebApplicationContext of Flowable BPMN Rest API, Flowable App Rest API and so on which registerec in org.flowable.spring.boot.RestApiAutoConfiguration class by BaseRestApiConfiguration?