What is API versioning
- API versioning helps you to manage and maintain different versions of endpoints.
- It allows the developer to add new functionality instead of changing the existing ones as some clients rely on an older version
Common ways to implement API versioning
- URL versioning: https://localhost:7091/api/v1/weatherForecast
- Header versioning: https://localhost:7091/api/weatherForecast -H 'X-Api-Version: 1'
- Query parameter versioning: https://localhost:7091/api/weatherForecast?api-version=1
Implement URL versioning
Create Project with .NetCore web api template
Install Nuget packages
Asp.Versioning.Mvc : Required for MVC controller end Point and
Asp.Versioning.Mvc.ApiExplorer: Required for ASP.NET Core API Versioning.
- Use AddApiVersioning to provide options for API versioning ApiVersioningOptions.
Added the definition of each line in the comment (refer to the above snapshot).
- At the controller level specify the supported API version.
- Postman Result
😍 If you enjoy the content, please 👍 like, 🔄 share, and 👣 follow for more updates!
Join me on a professional journey through my LinkedIn profile: Vaibhav Lande
Top comments (0)