如何在SpringDoc OpenAPI3中刷新文件?

问题描述 投票:0回答:1

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

这里是Webservice的示例正在处理:

    @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

我的问题是Swagger无法解析此引用ref =“#/ swagger / Planner / semi_planif_200_response.json”我什至尝试使用绝对路径,但它不起作用:The Error Message from swagger

这里是文件路径:

File path

java spring-boot swagger-ui openapi s
1个回答
0
投票

在编译时不会解析引用,而是在运行项目之后,swagger引擎将解析引用,因为它们是服务器中的静态资源:

 $ref= resources/swagger/user.json 

如果我们在本地主机中运行实例,则将从以下URL中获取资源:localhost:8080/resources/swagger/user.json

Tip:确保Spring资源处理程序将目标资源放在指定的位置!

© www.soinside.com 2019 - 2024. All rights reserved.