Swagger UI does not show Params

Viewed 548

I've got a Spring-Application (2.1.0.RELEASE) and added Swagger and Swagger-UI (2.9.2).

I have a SwaggerConfig class, that I copied from the Baeldung tutorial

Then, there is the App class:

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

@SpringBootApplication
@EnableAutoConfiguration
public class App
{
    public static void main(String[] args) throws Exception {
        SpringApplication.run(App.class, args);
    }
}

And there is the actual REST controller:

@RestController
public class TweetRating {

    @GetMapping("/{userid}/tweet")
    public static void getTweet(@PathVariable String userid){
        System.out.println("UserID: "+ userid);
    }

    @GetMapping("/")
    public static void isWorking(@RequestParam String id){
        System.out.println("ID: "+ id);
    }
}

The Swagger-UI just won't show the params of the methods. Neither the PathVariable not the RequestParam. Therefore, the "Try it out" function does not make any sense, of course. It looks like this:

Screenshot1 Screenshot2

Why is that and how can I solve it?

1 Answers

Try to apply enableUrlTemplating(true) in you SwaggerConfig :

@Configuration
@EnableSwagger2
public class SwaggerConfig {                                    
    @Bean
    public Docket api() { 
        return new Docket(DocumentationType.SWAGGER_2)  
          .select()                                  
          .apis(RequestHandlerSelectors.any())              
          .paths(PathSelectors.any())  
          .enableUrlTemplating(true)                        
          .build();                                           
    }

Also try this one :

@ApiOperation(value = "Dexcription of endpoint")
@RequestMapping
public String doSomething(@ApiParam(value = "Description of path vaiable")@PathVariable("/{code}")
Related