我正在尝试对我的小api做一些文档。当状态代码400时,我可以有2个可能的描述,我应该怎么做?我想做一些类似的事情:
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "description",
content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = StudentFullDTO.class))}),
@ApiResponse(responseCode = "400", description = "description" +
"ExceptionResponseObject", content = @Content),
@ApiResponse(responseCode = "400", description = "Odescription",
content = @Content)})
@PatchMapping("/{id}")
public ResponseEntity<StudentFullDTO> patch(@PathVariable String id,
@RequestBody @Valid Map<Object, Object> fields) {
StudentEntity studentEntity = studentEntityService.patchStudentEntity(id, fields);
StudentFullDTO studentFullDTO = modelMapperService.mapObjectToObjectOfEnteredClass(studentEntity, StudentFullDTO.class);
return new ResponseEntity<>(studentFullDTO, HttpStatus.OK);
}
是否可以多次定义相同的状态?
1条答案
按热度按时间c8ib6hqw1#
您需要合并这两个描述,并在同一个
@ApiResponse(description = "...")
注解中指定它们,这是因为OpenAPI规范只允许每个操作定义一次HTTP状态代码。