Skip to main content
ErrorOrX provides full support for ASP.NET Core API versioning through the Asp.Versioning.Http package. The generator automatically emits version sets and applies them to endpoints.
API versioning support was added in v3.1.0. Make sure you have the latest version of ErrorOrX.Generators.

Quick Start

Installation

If you use versioning attributes without the Asp.Versioning.Http package referenced, the generator emits EOE052 warning.

Attributes

[ApiVersion]

Declares which API versions an endpoint class or method supports.

[MapToApiVersion]

Maps a specific endpoint to a specific version. Required when multiple endpoints share the same route but serve different versions.

[ApiVersionNeutral]

Marks an endpoint as version-neutral (available on all versions). Use this for infrastructure endpoints like health checks.
[ApiVersionNeutral] and [MapToApiVersion] are mutually exclusive. Using both triggers EOE050 warning.

Version Formats

ErrorOrX supports multiple version formats:

Generated Code

The generator emits version sets and applies them to endpoints:

Version-Neutral Endpoints

Deprecated Versions

Service Registration

Register API versioning in your Program.cs:

Version Reader Options

Diagnostics

See Diagnostics for detailed examples and fixes.

OpenAPI Integration

Versioned endpoints automatically include version metadata in OpenAPI documentation:

Best Practices

1

Declare versions at class level

When all endpoints in a class share the same versions, declare them once at the class level.
2

Use MapToApiVersion sparingly

Only use [MapToApiVersion] when multiple endpoints share the same route but serve different versions.
3

Mark infrastructure as version-neutral

Use [ApiVersionNeutral] for health checks, metrics, and other infrastructure endpoints.
4

Deprecate before removing

Mark old versions as deprecated before removing them to give consumers time to migrate.

Complete Example