Table of Contents

AddRestfulApiVersioning Method

Definition

Namespace
Codebelt.Extensions.Asp.Versioning
Assemblies
Codebelt.Extensions.Asp.Versioning.dll
Source
src/Codebelt.Extensions.Asp.Versioning/ServiceCollectionExtensions.cs

AddRestfulApiVersioning(IServiceCollection, Action<RestfulApiVersioningOptions>)

Adds a compound service API versioning to the specified services collection that is optimized for RESTful APIs.

public static IServiceCollection AddRestfulApiVersioning(this IServiceCollection services, Action<RestfulApiVersioningOptions> setup = null)

Parameters

services IServiceCollection

The IServiceCollection to extend.

setup Action<RestfulApiVersioningOptions>

The RestfulApiVersioningOptions that may be configured.

Returns

IServiceCollection

A reference to services so that additional calls can be chained.

Remarks

This is a convenient method to add API versioning to your ASP.NET Core WebApi. Call AddApiVersioning, AddMvc and AddApiExplorer. Configuration, which is optimized for RESTful APIs, are done through setup. When DefaultApiVersion is a SemanticApiVersion, semantic aliases are automatically registered only for that default version. Applications that expose additional semantic versions and need aliases such as 2 or 2.0 should call AddApiVersionParser<T>(IServiceCollection, T) with CreateSemanticVersionAlias(IEnumerable<SemanticApiVersion>).