Skip to content

Remove id from post /mentors requests#540

Open
lulu-cao wants to merge 11 commits intoWomen-Coding-Community:mainfrom
lulu-cao:remove-id-from-post-mentor
Open

Remove id from post /mentors requests#540
lulu-cao wants to merge 11 commits intoWomen-Coding-Community:mainfrom
lulu-cao:remove-id-from-post-mentor

Conversation

@lulu-cao
Copy link
Contributor

@lulu-cao lulu-cao commented Mar 5, 2026

Description

This PR aims to resolve the 1st bullet point in #486. It hides id from 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 the id field, which allows the field to be returned during JSON serialization but ignores the field in client request during deserialization.

Related Issue

#486

Change Type

  • Bug Fix
  • New Feature
  • Code Refactor
  • Documentation
  • Test
  • Other

Screenshots

Before:
image

After:
image

Pull request checklist

Please check if your PR fulfills the following requirements:

@lulu-cao lulu-cao requested a review from a team as a code owner March 5, 2026 04:02
@lulu-cao lulu-cao changed the title Remove id from post mentor Remove id from post /mentors requests Mar 5, 2026
@Builder
public class MemberDto {
@Schema(accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add that in the Mentee?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 20c448e

@lulu-cao
Copy link
Contributor Author

@dricazenck I resolved a merge conflict in this PR. When doing git merge --continue, the command failed with this error .husky/pre-commit: line 15: ./gradlew: No such file or directory. But when manually running ./gradlew :pmdAll in the same directory (root directory), it appears found and successful. So, I ended up pushing the merge with git commit --no-verify.
Screenshot 2026-03-10 at 8 39 53 PM

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants