Summary
This chapter explored how easy it is to leverage web APIs and create web services that expose REST endpoints to share data over HTTP. We also saw how to decouple the model from the “presentation” using DTOs.
DTOs are the equivalent of view models, but for web services. They are classes specially crafted around a specific resource: an HTTP endpoint. Instead of returning raw data to the client, a DTO can encapsulate the result of computations, limit the number of exposed properties, aggregate results, and flatten data structures to carefully craft the API contract representing the input and output of its endpoint.
Then we dug a little further along that path by defining that DTOs are part of the API contract defining our web API, so its consumers know how to communicate with it. We also peeked at OpenAPI to help share the contracts in a more standard way.
Now that we explored principles and methodologies as well as a few ASP.NET Core bases like MVC...