Reputation: 41
I'm trying to build a REST api in Spring Boot and I'm in a dilemma regarding the Request Body. If an entity, ex. Doctor has a subentity let's say a specialization, should I pass only the id of the specialization or the entire entity.
First case
{
"contractId": 1,
"user": {
"firstname": "",
"lastname": "",
"email": "",
"phoneNumber": "",
"username": "",
"password": "",
"gender": "",
},
"roleId": 1,
"specializations": [
{
"id": 1
},
{
"id": 2
}
],
"qualifications": [
{
"id": 1
},
{
"id": 2
}
]
}
second case
{
"contractId": 1,
"user": {
"firstname": "",
"lastname": "",
"email": "",
"phoneNumber": "",
"username": "",
"password": "",
"gender": "",
},
"roleId": 1,
"specializations": [
{
"id": 1,
"name": "Specialization_1"
}
],
"qualifications": [
{
"id": 1,
"name": "Qualification_1"
},
{
"id": 2,
"name: "Qualification_2"
}
]
}
Upvotes: 0
Views: 880
Reputation: 448
if you know the Id before making this call and the id is always binded to certain specialization, then yes, only Id should be enough
Upvotes: 1