I've one spring boot rest controller method which is mapped to multiple mappings. Please find the example code below.
@RestController
public class HomeController {
@RequestMapping( {"/", "/home"} )
public String home() {
return "Hello, World!";
}
}
I want to hide /home
mapping from swagger documentation.
Can someone please help me to achieve this.
I also searched for a way to hide certain URLs from multi mapping methods. Unfortunately, I don't think it's possible when multi mapping it's defined like this @RequestMapping( {url1, url2} )
There are 2 alternative ways to do it:
Split your method into 2 methods that call the same function and annotate the one you want to hide with @Operation(hidden=true)
Define exceptions in your swagger config (for swagger 3 which uses open API):
@Configuration
public class SwaggerConfig {
@Bean
public GroupedOpenApi myApi()
{
return GroupedOpenApi.builder()
.pathsToMatch("/**")
.pathsToExclude("/home")
.build();
}
}