小编bac*_*tos的帖子

如何在 SpringDoc OpenAPI3 中引用文件?

我有 Springboot 项目,我想在其中记录我的 API:

这是正在处理的 Web 服务的示例:

    @ApiResponses(
        value = {
                @ApiResponse(responseCode = "200", content =  @Content(
                        mediaType = "*/*",
                        schema = @Schema(implementation = Object.class),
                        examples = {
                                @ExampleObject(name = "boo",
                                summary = "example of boo",
                                ref = "#/swagger/Planner/semi_planif_200_response.json")
                        }

                ))
        }
)
@PostMapping(value = "/startSemiPlanification", produces = "application/json")
private ResponseEntity<Object> startSemiPlanner( @RequestBody PlanificationDto planificationData,
                                                @RequestParam(name = "groupByUserCode", required = false) Optional<Boolean> groupByUserCode,
                                            @RequestParam(name = "range", defaultValue = "18") Integer range
Run Code Online (Sandbox Code Playgroud)

我的问题是 Swagger 无法解析此引用 ref = "#/swagger/Planner/semi_planif_200_response.json" 我什至尝试过使用绝对路径,但它不起作用: 来自 swagger 的错误消息

这是文件路径:

文件路径

java swagger-ui spring-boot openapi

8
推荐指数
1
解决办法
3727
查看次数

标签 统计

java ×1

openapi ×1

spring-boot ×1

swagger-ui ×1