springdoc-openapiサンプルのSakeController.java
@RestController | |
@RequestMapping("/sakes") | |
@RequiredArgsConstructor | |
public class SakeController { | |
private final SakeService sakeService; | |
@GetMapping | |
public Page<SakeResponse> page(@PageableDefault Pageable pageable) { | |
return sakeService.page(pageable); | |
} | |
@GetMapping("list") | |
public List<SakeResponse> list() { | |
return sakeService.list(); | |
} | |
@GetMapping("{id}") | |
public SakeResponse get(@PathVariable Integer id) { | |
return sakeService.get(id); | |
} | |
@PostMapping | |
public SakeResponse create(@RequestBody @Validated SakeCreateRequest request) { | |
return sakeService.create(request); | |
} | |
@ResponseStatus(HttpStatus.BAD_REQUEST) | |
@ExceptionHandler(NotFoundException.class) | |
public ResponseEntity<ErrorResponse> handleException(NotFoundException e) { | |
return ResponseEntity.of(Optional.of(new ErrorResponse(e.getMessage()))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment