我的 Spring Boot 应用程序中有两种方法,RequestMapping
一种返回JSON
,另一种返回returns byte[]
public class UserApiController implements UserApi
@RequestMapping(value="/getUser/{userId}",
produces = {"application/json"},
consumes = {"application/json"},
method = RequestMethod.GET)
public ResponseEntity<UserModel> getUser(@PathVariable("userId")String userId){
//returns UserModel JSON
}
@RequestMapping(value="/getUser/{userId}",
produces = {"application/pdf"},
consumes = {"application/pdf"},
method = RequestMethod.GET)
public ResponseEntity<byte[]> getUserPDF(@PathVariable("userId")String userId){
//returns byte[] of pdf
}
我通过OpenApi
using .yaml
using生成接口openapi-generator-cli-3.3.0.jar
当我生成接口时,我的接口生成这样的方法
@RequestMapping(value="/getUser/{userId}",
produces = {"application/json","application/pdf"},
method = RequestMethod.GET)
public ResponseEntity<UserModel> getUser(@PathVariable("userId")String userId);
我怎样才能强制它制作两种单独的方法而不是一种?