[英]How to document swagger specification which returns ResponseEntity<Resource> where Resource is org.springframework.core.io.Resource
I have a rest end point which returns ResponseEntity<Resource>
. 我有一个休息的终点,它返回
ResponseEntity<Resource>
。
Need to check how can I create this type of response in Swagger specification. 需要检查如何在Swagger规范中创建此类响应。 Here Resource from package is
org.springframework.core.io.Resource
包中的资源是
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;
}
Here is the part of my swagger specs file. 这是我不拘一格的规格文件的一部分。 I need to know how to document its schema type in type section
我需要知道如何在类型部分中记录其架构类型
"/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": *********
}
}
}
can you try to return, 你能尝试返回吗
@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);
}
You can try, 你可以试试,
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.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.