AV0003: Invalid API version status
| Value | |
|---|---|
| Rule ID | AV0003 |
| Category | Usage |
| Fix is | Breaking |
Cause
The specific API version status is invalid.
Rule Description
An API version status must start with a letter and may contain letters, digits, and periods. The status not end with a period.
Consider the following code:
[ApiController]
[ApiVersion(2.0, "preview-1")]
[Route("[controller]")]
public class ExampleController : ControllerBase
{
[HttpGet]
public IActionResult Get() => Ok();
}
The text "preview-1" is not a valid API version status. This would not detected until runtime.
How to Fix Violations
Update the API version status to be well-formed.
[ApiController]
[ApiVersion(2.0, "preview.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 text is parsed.