Missing Api Response Type (ARCH4201)
Ce contenu n’est pas encore disponible dans votre langue.
Key java.quality.missing-api-response · Severity info · Category quality
Actions that don’t declare their response status codes leave the generated OpenAPI docs incomplete. Annotate the expected status codes explicitly.
Incorrect
Section titled “Incorrect”@PostMapping("/orders")public Order create(@RequestBody Order order) { return service.create(order);}Correct
Section titled “Correct”@PostMapping("/orders")@ApiResponses({ @ApiResponse(responseCode = "201", description = "Created"), @ApiResponse(responseCode = "400", description = "Invalid input")})@ResponseStatus(HttpStatus.CREATED)public Order create(@RequestBody @Valid Order order) { return service.create(order);}Annotate the action with @ResponseStatus and @ApiResponse to declare its expected status codes.