相关疑难解决方法(0)

如何使用Swagger注释在Swagger中设置描述和示例?

我正在使用Spring启动创建REST Api,并使用swagger codegen在控制器中自动生成swagger文档.但是,我无法在POST请求中为String类型的参数设置描述和示例.这是mi代码:

import io.swagger.annotations.*;

@Api(value = "transaction", tags = {"transaction"})
@FunctionalInterface
public interface ITransactionsApi {
    @ApiOperation(value = "Places a new transaction on the system.", notes = "Creates a new transaction in the system. See the schema of the Transaction parameter for more information ", tags={ "transaction", })
    @ApiResponses(value = {
        @ApiResponse(code = 200, message = "Another transaction with the same messageId already exists in the system. No transaction was created."),
        @ApiResponse(code = 201, message = "The transaction has been …
Run Code Online (Sandbox Code Playgroud)

java spring swagger swagger-codegen

31
推荐指数
3
解决办法
3万
查看次数

如何在 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
查看次数