I'm having a trouble with updates in a Api C# Client generated with NSwag and how to use the HTTP PUT verb.
Let's say I have a DTO called customer
public class CustomerDTO
{
public int id { get; set; }
public string name{ get; set; }
public string email { get; set; }
}
I have a consumer of that C# Client that wants to modify the customer e-mail.
So he creates a call to CustomerPut to replace the resource.
CustomerDTO customer = await CustomerGet(); // Performs a get on the entity
customer.email = "newemail@abc.com";
await CustomerPut(customer);
All right for the moment.
The problem arises when I decided to add a new field into the CustomerViewModel
public class CustomerDTO
{
public int id { get; set; }
public string name{ get; set; }
public string email { get; set; }
public string? likesApples {get; set;}
}
If I ever do that, the code in my consumer has to be updated, or he will unset the likesApples property. It means the value from likesApples wil get erased every time the outdated client tries to update something.
Is there a solution so I don't have to update my client code for every new simple field I want to add?