AI Risk Classification System: Day 9
Introduction
Today, I continued working on the backend integration process by adding input validation annotations and API documentations
Development Notes
Input Validation
First of all, I added a spring-boot-starter-validation dependency to the pom.xml file
Then, I updated the ClassificationRequest class with valid annotations by using @NotBlank for required fields (e.g. systemName and systemPurpose) and @Size to validate requests
I also modified the controller to use @Valid annotation and added an exception handler that returns HTTP 400 for bad requests and error messages
API Documentation
First, I added a springdoc-openapi-starter-webmvc-ui dependency to the pom.xml file
Added documentation to the controller by using @Tag for API grouping, @Operation for endpoint description, and @ApiResponses for possible responses
Added documentation to the request and response classes by using @Schema to enhance documentation for API and Swagger UI (I also added examples for better understanding
Now I can run Swagger UI on http://localhost:8080/swagger-ui.html, and everything seems to work properly (the correct endpoints are visible)