POST请求的Springfox自定义RequestBody

时间:2020-09-02 07:53:49

标签: spring-boot swagger swagger-ui springfox

我有一个名为Record的模型类:

import lombok.*;

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Record {
    @Schema(required = true, description = "Received bundle",
            example = "{'name':'John','lastName':'Doe'}")
    private String bundle;
}

该服务将Record用作RequestBody

@Operation(
        summary = "Summary",
        description = "Description",
        responses = {
                @ApiResponse(responseCode = "200", description = "Success")
        }
)
@PostMapping(
        value = "report",
        consumes = APPLICATION_JSON_VALUE
)
public ResponseEntity<Void> report(@RequestBody Record record) {
    System.out.println(record.getBundle());
    return ResponseEntity.ok().build();
}

当我打开swagger-ui时,示例值如下:

{
  "bundle": "{'name':'John','lastName':'Doe'}"
}

相反,我想要以下内容:

{
  'name':'John',
  'lastName':'Doe'
}

如何实现?

0 个答案:

没有答案
相关问题