jasontaylordev / NorthwindTraders

Northwind Traders is a sample application built using ASP.NET Core and Entity Framework Core.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: How to design projects to support versioning?

ikyriak opened this issue · comments

Hello,

In case we would like to support different versions of our Web API (for backwards compatibility),
do you have a suggestion or an example?

There are suggestions regarding the controllers (https://github.com/microsoft/aspnet-api-versioning), but how can this be applied in Clean Architecture?

Yes, the recommended approach is to not expose the command and queries as DTOs through the API, e.g. don’t expose CreateCustomerCommand. Instead, within each version create request DTOs within the API that are exposed, e.g. CreateCustomerRequest. The API will be responsible for converting these DTOs into the relevant command or query.

You can then support multiple API versions and also modify command and query DTOs without changing the API.

Hope this helps. 😀