I am trying to do some documentation to my small api. What should I do in situation when on status code 400 I can have 2 possible descriptions? I would like to do something like:
@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);
}
Is it possible to define the same status multiple times?
You'll need to merge the two descriptions and specify them within the same @ApiResponse(description = "...")
annotation. This is because OpenAPI Specification only allows defining each HTTP status code once per operation.
@ApiResponse(responseCode = "400",
description = "Possible reasons: reason 1; reason 2",
content = @Content),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.