bac*_*tos 8 java swagger-ui spring-boot openapi
我有 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
我的问题是 Swagger 无法解析此引用   ref = "#/swagger/Planner/semi_planif_200_response.json"   我什至尝试过使用绝对路径,但它不起作用:

这是文件路径:
引用不会在编译时解析,而是在运行项目后,swagger 引擎将解析引用,因为它们是服务器内的静态资源:
 $ref= resources/swagger/user.json 
如果我们在 localhost 中运行实例,则将从以下 url 获取资源:localhost:8080/resources/swagger/user.json
提示:确保 Spring 资源处理程序将目标资源放置在指定位置!
| 归档时间: | 
 | 
| 查看次数: | 3727 次 | 
| 最近记录: |