Can I use swagger if I deploy Camunda using Spring Boot?

Your youtube tutorials used Swagger by using Camunda Platform Run. On the other hand, I was following that same tutorial for which I used Spring Boot’s own container. When I went to localhost:8080/swaggerui/, I got Whitelabel Error Page.

Can you tell me what do I need to do in order for this to work? Am I missing something?

The swagger UI only comes pre-installed on the Camunda Run distribution. If you want to add it to your spring boot project you would need to do this yourself.

@stefanpg i had success using swagger in a springboot project with camunda. You can see this simple example in my github:

The important parts are the springfox dependencies in build.gradle:

implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '3.0.0'

And the config class in wich you configure the packages you want to expose in swagger page:

package br.com.hypeflame.example.camundaspring.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2

public class SwaggerConfig {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2).select()
                .apis(RequestHandlerSelectors.basePackage("br.com.hypeflame.example.camundaspring"))
                .paths(PathSelectors.any()).build();
    }
}
2 Likes

Hello Jean,

This enable swagger to expose your package. How can i expose camunda rest api like in Camuna Run distribuition?

Tried this:

package gov.sti.gegov;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2

public class SwaggerConfig {
    
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2).select()
                .apis(RequestHandlerSelectors.basePackage("org.camunda.bpm.engine.rest"))
                .paths(PathSelectors.any()).build();
    }

}

But no operations defined in spec!

swagger

Thanks