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
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.
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 yourProgram.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.
