有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

在swagger注释中具有参数化类的java

从我的春季休息服务中,我回复如下-

return new ResponseEntity<ExampleOutputData>(exampleService.exampleServiceCall(inputData), responseHeaders, HttpStatus.ACCEPTED);

我在注释中提到的回应是——

 @ApiResponses(value = { 
            @ApiResponse(code = 202, message = "Success", response = ResponseEntity.class)}) 

我收到的yaml文件回复为-

  responses:
    202:
      description: "Success"
      schema:
        $ref: "#/definitions/ResponseEntity"

我的问题是如何在响应中提到ExampleOutputData,因为实际上我的响应是ResponseEntity<ExampleOutputData>

或者它不是必需的,并且当前的实现和招摇过市的定义是完美的


共 (1) 个答案

  1. # 1 楼答案

    为了在响应中包含ExampleOutputData,您只需将ResponseEntity.class更改为ExampleOutputData.class

    @ApiResponses(value = {@ApiResponse(code = 202, message = "Success", response = ExampleOutputData.class)})
    

    见文件here