As I know about designing of REST-API's in SpringBoot we will design API's for User like
For ADD User = /v1/users (Add a single object into a user collection)
For GET/UPDATE/DELETE user = /v1/users/{userId} (for get/update/delete a single object from users collection)
Now We also design an API's for User Address like
For Add Address = /v1/users/{userId}/addresses (Add a single object into addresses of user followed by userId)
For GET/UPDATE/DELETE = /v1/users/{userId}/addresses/{addressId} (get/update /delete of address from addresses for a user of given userId)
So, I have created API's like this but for add/get/update/delete I can direct addresses into Address table via RestController -> Services -> Repository -> DB
Now for Address CRUD I'm never used {userId} which is provided in API
Sample for Add/Update address
@Override
public Address addAddress(Address address) {
address = addressRepository.save(address);
return address;
}
Is there I'm doing something wrong in code or my concept about rest is not cleared.
Thank you in advance.