AV0007: Invalid API version day
| Value | |
|---|---|
| Rule ID | AV0007 |
| Category | Usage |
| Fix is | Breaking |
Cause
An API version expressed an invalid day.
Rule Description
When an API version is expressed as a date, the specified day must be valid.
Consider the following code:
[ApiController]
[ApiVersion(2026, 1, 32)]
[Route("[controller]")]
public class ExampleController : ControllerBase
{
[HttpGet]
public IActionResult Get() => Ok();
}
The day 32 is not a valid API version. The day must be between 1 and 31. This would not detected until runtime.
How to Fix Violations
Update the API version to be well-formed.
[ApiController]
[ApiVersion(2026, 1, 1)]
[Route("[controller]")]
public class ExampleController : ControllerBase
{
[HttpGet]
public IActionResult Get() => Ok();
}
When to Suppress Warnings
It is never safe to suppress this rule because a runtime exception will be thrown when the attribute is initialized.