Remove id from post /mentors requests#540
Open
lulu-cao wants to merge 11 commits intoWomen-Coding-Community:mainfrom
Open
Remove id from post /mentors requests#540lulu-cao wants to merge 11 commits intoWomen-Coding-Community:mainfrom
lulu-cao wants to merge 11 commits intoWomen-Coding-Community:mainfrom
Conversation
dricazenck
reviewed
Mar 5, 2026
| @Builder | ||
| public class MemberDto { | ||
| @Schema(accessMode = Schema.AccessMode.READ_ONLY) | ||
| @JsonProperty(access = JsonProperty.Access.READ_ONLY) |
Collaborator
There was a problem hiding this comment.
Could you also add that in the Mentee?
dricazenck
approved these changes
Mar 5, 2026
Contributor
Author
|
@dricazenck I resolved a merge conflict in this PR. When doing |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Description
This PR aims to resolve the 1st bullet point in #486. It hides
idfrom request body for POST /mentors requests.From my understanding, the best practice is to create a dto for each type of requests, createMentorDto for post requests, updateMentorDto for put requests, etc. But that's in the situation where there's a larger team supporting a more complex architecture. So, I chose to using swagger property @Schema to inform swagger to hide id from post request body instead. In the backend, we have
toMentor()method in MentorDto and MentorshipController that would ignore the id in the post requests so we don't need to be concerned about id manipulation.@Schema(accessMode = Schema.AccessMode.READ_ONLY)in front of a specific field allows this field to show up in response body but hides it from request body. In addition,@JsonProperty(access = JsonProperty.Access.READ_ONLY)was added in front of theidfield, which allows the field to be returned during JSON serialization but ignores the field in client request during deserialization.Related Issue
#486
Change Type
Screenshots
Before:

After:

Pull request checklist
Please check if your PR fulfills the following requirements: