ここに私の設定ファイルがあります:
@Configuration
@EnableSwagger2
@EnableWebMvc
public class SwaggerConfig {
@Bean
public Docket api() {
Docket result = new Docket(
DocumentationType.SWAGGER_2).select().apis(
RequestHandlerSelectors.any()).paths(
PathSelectors.any()).build();
return result;
}
}
と:
@Configuration
@EnableWebMvc
public class MyWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler(
"swagger-ui.html").addResourceLocations(
"classpath:/META-INF/resources/");
registry.addResourceHandler(
"/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/");
}
}
ここに私が持っている簡単なコントローラーがあります:
@RestController
@RequestMapping("/")
public class TestingController extends AbstractController {
@RequestMapping(value = "/play", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public ResponseDTO foo(@RequestBody RequestDTO requestDTO) throws IOException {
return this.myService.exec(requestDTO);
}
なぜかURL:
http://localhost:8080/app/v2/api-docs
私に次のことを与えます:
{"swagger":"2.0","info":{"description":"Api Documentation","version":"1.0","title":"Api Documentation","termsOfService":"urn:tos","contact":{},"license":{"name":"Apache 2.0","url":"http://www.apache.org/licenses/LICENSE-2.0"}},"host":"localhost:8080","basePath":"/app"}
多くのコントローラーとメソッドがありますが、それらが表示されないのはなぜですか? PS - ザ
Docket result = ...
パス\ルートが返されないようです。なぜですか?