我需要为我的Spring Boot2项目集成OpenAPI 3文档。我们没有在控制器上使用模态/DTO。
下面是示例控制器:
@RestController
@RequestMapping(value = "/pet")
public class PetController {
@RequestMapping(value = "/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<Map<String, Object>> savePet(
@RequestBody Map<String, Object> petObj, HttpServletRequest request)
throws Exception {
String petResponse = petDAO.savePet(petObj, request, true);
return new ResponseEntity<Map<String, Object>>(petResponse, HttpStatus.OK);
}
}请求正文:
{
"name":"Test",
"category":"school"
}我的回答是:
{
"petId":"1",
"petName":"Test",
"petCategory":"school",
"petStaus":"active"
}我找不到一种方法为我的自定义地图对象添加OpenAPI文档。我想为我的地图中的每个属性手动添加key,description,type,example(s)。
有谁能建议如何做到这一点吗?
发布于 2020-12-02 19:23:42
这是springdoc-openapi库的默认行为,以便忽略Spring MVC支持的其他可注入参数。
如果你想改变这个行为,你只需要如下所示:
SpringDocUtils.getConfig().removeRequestWrapperToIgnore(Map.class);https://stackoverflow.com/questions/64986204
复制相似问题