Cannot get my endpoints list from controller in swagger UI

I am new to Spring boot with Swagger UI. I’m just trying to configure my Rest controller endpoints to show on swagger UI screen but it shows No operations for specs defined. Pretty sure, its a configuration issue.

I have tried @EnableAutoConfiguration, still it can’t find the controller

package com.example.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class SwaggerDemoApplication {
    public static void main(String[] args) {, args);


package com.example.config;

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


public class SwaggerConfig {

 public Docket productApi() {
     return new Docket(DocumentationType.SWAGGER_2)  


package com.example.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;

@RequestMapping(value = "/test")
@Api(value="onlinestore", description="Operations pertaining to products in Online Store")
public class TestController {

    @RequestMapping(value = "/test-swagger", method= RequestMethod.GET)
    public String home() {
        return "Spring is here!";


Expected: Rest endpoint Actual: No operations defined in spec


The problem is not your Swagger Configuration but your Controller is not scanned as Spring resource class.

Because your application startup class (Main class) has no @ComponentScan annotation.

So, your class should be like this:

public class SwaggerDemoApplication {
    public static void main(String[] args) {, args);

Now you can access your API documentation from here http://localhost:8098/swagger-ui.html#

Leave a Reply

Your email address will not be published. Required fields are marked *