简体   繁体   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

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.

相关问题 如何处理Swagger Codegen的org.springframework.core.io.Resource - How to handle org.springframework.core.io.Resource for Swagger Codegen 如何模拟 org.springframework.core.io.Resource object? - How to mock org.springframework.core.io.Resource object? java.lang.ClassNotFoundException: org.springframework.core.io.Resource - java.lang.ClassNotFoundException: org.springframework.core.io.Resource 为 org.springframework.core.io.Resource 对象分配名称 - Assigning name to a org.springframework.core.io.Resource object org.springframework.web.multipart.MultipartFile 和 org.springframework.core.io.Resource 之间的转换 - Conversion between org.springframework.web.multipart.MultipartFile and org.springframework.core.io.Resource 为什么JasperReports尝试加载org.springframework.core.io.Resource类? - Why does JasperReports try to load org.springframework.core.io.Resource class? ClassNotFoundException:IntelliJ IDEA在tomcat7上部署Maven Spring MVC Web项目时出现org.springframework.core.io.Resource - ClassNotFoundException: org.springframework.core.io.Resource when intellij idea deploy maven spring mvc web project on tomcat7 Spring MVC“找不到能够将java.lang.String类型转换为org.springframework.core.io.Resource类型的转换器” - Spring MVC “No converter found capable of converting from type java.lang.String to type org.springframework.core.io.Resource” java.lang.NoClassDefFoundError: org/springframework/core/io/Resource 异常 - java.lang.NoClassDefFoundError: org/springframework/core/io/Resource Exception spring org.springframework.core.io.UrlResource不支持https资源 - spring org.springframework.core.io.UrlResource not support https resource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM