I have a rest end point which returns ResponseEntity<Resource>
.
Need to check how can I create this type of response in Swagger specification. Here Resource from package is 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.