繁体   English   中英

如何记录将返回ResponseEntity的表格规范 <Resource> 其中Resource是org.springframework.core.io.Resource

[英]How to document swagger specification which returns ResponseEntity<Resource> where Resource is org.springframework.core.io.Resource

我有一个休息的终点,它返回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;
}

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

"/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.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM