-
Notifications
You must be signed in to change notification settings - Fork 707
Deprecating a Service Version
When a service supports multiple API versions, some versions will eventually be deprecated over time. To advertise that one or more API versions have been deprecated, simply decorate your controller with the deprecated API versions. A deprecated API version does not mean the API version is not supported. A deprecated API version means that the version will become unsupported after six months or more.
The following examples illustrate how to specify deprecated API versions depending on which service API versioning approach you selected:
[ApiVersion( "2.0" )]
[ApiVersion( "1.0", Deprecated = true )]
[Route( "api/[controller]" )]
public class HelloWorldController : Controller
{
[HttpGet]
public string Get() => "Hello world!"
[HttpGet, MapToApiVersion( "2.0" )]
public string GetV2() => "Hello world v2.0!";
}
[ApiVersion( "2.0" )]
[ApiVersion( "1.0", Deprecated = true )]
[Route( "api/v{version:apiVersion}/[controller]" )]
public class HelloWorldController : Controller
{
[HttpGet]
public string Get() => "Hello world!"
[HttpGet, MapToApiVersion( "2.0" )]
public string GetV2() => "Hello world v2.0!";
}
To permanently sunset a service, simply remove that controller or API version from your implementation. The route will no longer be matched. When one or more specific API versions cannot be matched, clients will receive HTTP status code 400 (Bad Request). If no candidate routes match at all, clients will receive HTTP status code 404 (Not Found).
- Home
- Quick Starts
- Version Format
- Version Discovery
- Version Policies
- How to Version Your Service
- API Versioning with OData
- Configuring Your Application
- Error Responses
- API Documentation
- Extensions and Customizations
- Known Limitations
- FAQ
- Examples