I’m working on a Spring Boot application (version 3.2.4) and using Springdoc OpenAPI (version 2.0.4) to generate API documentation. However, when I open Swagger UI, I see the message “No operations defined in spec!”.
This is my whole project.
Here are the relevant details of my setup:
pom.xml (dependencies related to Springdoc OpenAPI):
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.4</version>
</dependency>
SetupController.java:
package blossom.reports_service.inbound;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import blossom.reports_service.model.ChallengeSummary;
import blossom.reports_service.model.ReportsService;
@RestController
@RequestMapping("/setup")
public class SetupController {
private final ReportsService reportsService;
@Autowired
public SetupController(ReportsService reportsService) {
this.reportsService = reportsService;
}
@PostMapping("/createChallengeSummary/{userId}")
public ChallengeSummary createChallengeSummary(@PathVariable Long userId) {
return reportsService.createChallengeSummary(userId);
}
}
I’ve ensured the following:
- All controllers are annotated with @RestController.
- The package structure is correct, and the main application class is in the root package.
- The application starts without any errors.
- Accessing Swagger UI via http://localhost:8080/swagger-ui/index.html.
Despite these steps, Swagger UI still shows “No operations defined in spec!”. Any help or suggestions would be greatly appreciated!
Adrian Krafft is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.