↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

API Versioning In ASP.NET Core

The article explains why API versioning is needed when an application grows and existing clients still depend on older behavior. It then shows how to set up ASP.NET Core Web API versioning with a NuGet package and a default version in Startup.cs.

Reading notes
#

  • API versioning helps add new functionality to existing Web APIs without breaking current consumers.
  • The setup uses the Microsoft.AspNetCore.Mvc.Versioning package.
  • ConfigureServices sets a default API version, makes the default apply when the client does not specify one, and reports versions in response headers.
  • The article uses EmployeeV1Controller and EmployeeV2Controller to show separate versions of the same endpoint.
  • Query string versioning passes the version as api-version in the request URL.
  • URL versioning places the version in the route, such as api/1.0/employee and api/2.0/employee.
  • Header versioning reads the version from an x-api-version header through HeaderApiVersionReader.
  • The article closes by restating that the three methods covered are query string, URL, and HTTP header versioning.