When I create my HTTP API, I put the model objects (DTO, request models, etc.) in a separate assembly that I can distribute to .NET clients.
Consider the following class:
public abstract class UserUpdateRequestModel { [Required] [StringLength(50)] public string Name { get; set; } [Required] [EmailAddress] [StringLength(320)] public string Email { get; set; } }
This is what I use in my API:
public UserDto PutUser(Guid key, UserUpdateRequestModel requestModel) {
You can use the same model in an ASP.NET MVC client application, for example, to generate HTML inputs with data- validation data- , because ASP.NET MVC has a way to generate data based on data annotation validation attributes.
tugberk
source share