我想在OpenApi中映射这个rest接口吗?有没有偶然的工具,我可以用它从rest接口创建一个OpenApi,而不需要在我的中包含这个工具?或者有一个模板可以自己用Openapi构建界面呢?如果有办法,我将不胜感激。
@GetMapping("/page")
public Page<FootballTeamLocationEntityView> getPageableFootballTeamList(@PageableDefault(value = 10) Pageable pageable) {
return footballTeamService.getFootballTeams(pageable);
}我使用OpenApi 3.0和Spring 2
更新1
default ResponseEntity<FootballTeamLocation> getPageableFootballTeamList(Pageable pageable) {
getRequest().ifPresent(request -> {
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
String exampleString = "{ \"name\" : \"Westfalen-Stadion\", \"locZ\" : 5.962133212312, \"externalId\" : \"externalId\", \"locX\" : 6.02749381870403, \"id\" : 0, \"locY\" : 11.4658129805029452 }";
ApiUtil.setExampleResponse(request, "application/json", exampleString);
break;
}
}
});
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);发布于 2021-10-28 09:05:35
考虑使用springdoc。这是最近的一个库,它比Springfox (Springfox应用程序的另一个选项)更易于使用,也更不容易出错。我们两年前搬到这里,我们很高兴我们做到了。网上有非常好的文档和教程:
它也非常活跃,您通常会在github页面上很快地回答您的问题。
https://stackoverflow.com/questions/69751042
复制相似问题