Table of Contents

Class ApiVersioningExtensions

Namespace
Arc4u.AspNetCore.Versioning
Assembly
Arc4u.AspNetCore.Versioning.dll

Registers the api versioning used by the interface endpoints.

public static class ApiVersioningExtensions
Inheritance
ApiVersioningExtensions
Inherited Members

Fields

VersionHeader

The header used to give the api version.

public const string VersionHeader = "x-api-version"

Field Value

string

VersionQueryString

The query string parameter used to give the api version.

public const string VersionQueryString = "api-version"

Field Value

string

Methods

AddServiceApiVersioning(IServiceCollection)

Adds api versioning where the version is read from the url segment (v1), the VersionHeader header or the VersionQueryString query string.

public static IServiceCollection AddServiceApiVersioning(this IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to register the api versioning to.

Returns

IServiceCollection

The IServiceCollection.

Examples

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddServiceApiVersioning();

Remarks

The default version is V1, but a version is mandatory (it is not assumed when missing), supported versions are reported in the response headers and the API explorer substitutes the version in the documented URLs.

Exceptions

ArgumentNullException

services is null.