-
Notifications
You must be signed in to change notification settings - Fork 29
feat: adds Trinitie's lesson_23 hw about Web APIs using REST #735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
anthonydmays
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎓 Automated Grading Report
Student: Trinitie Jackson
Date: 10/7/2025
Feedback
The submission demonstrates a good understanding of API development and HTTP protocol concepts. The student has implemented the required endpoints, including GET, POST, and DELETE operations, and has made appropriate use of the Spring framework annotations. However, there are some discrepancies compared to the sample solution. For instance, the getItemById method uses GetMediaItemsResponse instead of MediaItemResponse, which might not align with expected response structures. Additionally, the addNewItem method does not use the @Valid annotation for request validation, which could lead to issues if the request object is malformed. The use of Map for error responses is a good approach, but it deviates from the sample solution's use of specific response classes, which might affect consistency and clarity. The code is generally well-formatted, but there are some unnecessary imports and reordering of imports that could be cleaned up. Overall, the code is functional and technically sound, but there are areas for improvement in aligning with the sample solution and ensuring consistency in response handling.
This is an automated preliminary review. Please review and adjust before finalizing.
|
I have just made the adjustments with the feedback given. |
| @PostMapping("/items") | ||
| public ResponseEntity<?> addNewItem( | ||
| @Valid @RequestBody(required = false) CreateMediaItemRequest request) { | ||
| if (request == null || request.getItem() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need this.
| MediaItem item = MediaItemRequest.asMediaItem(request.getItem()); | ||
| library.addMediaItem(item, librarian); | ||
| return ResponseEntity.ok(Map.of("item", MediaItemResponse.from(item))); | ||
| } catch (IllegalArgumentException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need this either if you just use the @Valid annotation (which you did).
| } | ||
|
|
||
| @DeleteMapping("/items/{id}") | ||
| public ResponseEntity<Void> deleteItem(@PathVariable String id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Better to take a UUID.
This is my lesson_23 homework on Web APIs using REST.
Added the MediaItemsController to handle API requests for the library app.
Includes GET, POST, and DELETE routes for media items with validation and error handling.
All tests in MediaItemsControllerTest now pass successfully.
For this homework, it was interesting to see how the methods came out to cover the tests. I struggled a bit with the post method as there seemed to be many different ways to do it.