gpt4 book ai didi

java - 如何记录返回 ResponseEntity 的 swagger 规范,其中 Resource 是 org.springframework.core.io.Resource

转载 作者:太空宇宙 更新时间:2023-11-04 09:26:09 28 4
gpt4 key购买 nike

我有一个返回 ResponseEntity<Resource> 的休息终点.
需要检查如何在 Swagger 规范中创建这种类型的响应。这里包中的资源是 org.springframework.core.io.Resource

@GetMapping("/downloadZip/{cycleId}")
public ResponseEntity<Resource> downLoadDATFileAsZip(@RequestParam(value ="cycleId", required = false) String cycleId) {
//generating zip file and returning as
return responseEntity;
}

这是我的 swagger 规范文件的一部分。我需要知道如何在类型部分记录其架构类型

"/downloadZip/{cycleId}" :{
"get" : {
"operationId": "downLoadDATFileAsZip",
"parameters": [
{
"name": "cycleId",
"in": "path",
"description": "Indicates the folder name from which file CDRrst.dat file is to be downloaded",
"required" :true,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK. Successfully processed the request",
"schema": {
"type": *********
}
}
}

最佳答案

你能尝试返回吗,

@ApiOperation(value = "View a list of available Resource", response = Resource.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully retrieved list"),
@ApiResponse(code = 401, message = "You are not authorized to view the resource"),
@ApiResponse(code = 403, message = "Accessing the resource you were trying to reach is forbidden"),
@ApiResponse(code = 404, message = "The resource you were trying to reach is not found")
})
@GetMapping("/downloadZip/{cycleId}")
public ResponseEntity<Resource> downLoadDATFileAsZip(@RequestParam(value ="cycleId", required = false) String cycleId) {
//generating zip file and returning as
Resource rscr = new Resource();
return ResponseEntity.ok().body(rscr);
}

你可以试试

  responses:
'200':
description: A list of users
content:
application/json:
schema:
type: object
properties:
id:
type: integer
description: The user ID.
username:
type: string
description: The user name.

关于java - 如何记录返回 ResponseEntity<Resource> 的 swagger 规范,其中 Resource 是 org.springframework.core.io.Resource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57689571/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com