Estou tentando configurar o Swagger 2 para uma API do Spring Boot 3. Estou recebendo esta mensagem ao acessar a interface do Swagger: "No operations defined in spec!". Não estou obtendo nenhuma operação definida na minha classe de Controller.
SwaggerConfig:
package br.com.api.sise.fatweb.manter;
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.bradseg.sise.fatweb.manter.rest"))
.paths(PathSelectors.any())
.build();
}
}
Controller
package br.com.api.sise.fatweb.manter.rest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
@Api(value = "Health")
@RequestMapping("/health")
public class HealthRest {
@ApiOperation(value = "Mostra se a aplicação está funcionando")
@GetMapping("/check")
public ResponseEntity<String> check() {
return new ResponseEntity<>("Aplicação operando com sucesso", HttpStatus.OK);
}
}
Main:
package br.com.api.sise.fatweb.manter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.jms.annotation.EnableJms;
@SpringBootApplication
@EnableJms
@ComponentScan(basePackages = "br.com.bradseg.sise.fatweb.manter")
public class SiseSrvFatwebManterApplication {
public static void main(String[] args) {
SpringApplication.run(SiseSrvFatwebManterApplication.class, args);
}
}
pom.xml (não contém tudo, para economizar espaço):
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>provided</scope>
</dependency>
<!-- Swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.1.0</version>
</dependency>
application.properties:
springdoc.api-docs.enabled=true
springdoc.packages-to-scan=*
springdoc.swagger-ui.path=/swagger-ui.html
springdoc.api-docs.path=/v3/api-docs
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
spring.profiles.active=dev
server.servlet.context-path=/sise-srv-fatweb-manter
server.port=8081
O JSON que é retornado para mim no caminho /api-docs informa que não tem nenhum caminho (paths): {"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost:8081/sise-srv-fatweb-manter","description":"Generated server url"}],"paths":{},"components":{}}
Eu já pesquisei tanto sobre o assunto, mas sinceramente não sei mais o que fazer. Estou estressado com tudo isso. Desde já agradeço por qualquer ajuda.