33namespace Asp . Versioning . ApiExplorer ;
44
55using Asp . Versioning . Routing ;
6+ using Microsoft . AspNetCore . Http ;
67
78/// <content>
89/// Provides additional implementation specific to ASP.NET Core.
@@ -37,7 +38,7 @@ public ApiVersion DefaultApiVersion
3738 /// <value>The <see cref="IApiVersionParameterSource">API version parameter source</see> used to describe API version parameters.</value>
3839 public IApiVersionParameterSource ApiVersionParameterSource
3940 {
40- get => parameterSource ??= ApiVersionReader . Combine ( new QueryStringApiVersionReader ( ) , new UrlSegmentApiVersionReader ( ) ) ;
41+ get => parameterSource ??= ApiVersionReader . Default ;
4142 set => parameterSource = value ;
4243 }
4344
@@ -47,6 +48,17 @@ public IApiVersionParameterSource ApiVersionParameterSource
4748 /// <value>The name associated with the <see cref="ApiVersionRouteConstraint">API version route constraint</see>.</value>
4849 public string RouteConstraintName { get ; set ; } = string . Empty ;
4950
51+ /// <summary>
52+ /// Gets or sets the API version selector.
53+ /// </summary>
54+ /// <value>An <see cref="IApiVersionSelector">API version selector</see> object.</value>
55+ [ CLSCompliant ( false ) ]
56+ public IApiVersionSelector ApiVersionSelector
57+ {
58+ get => apiVersionSelector ??= new DefaultApiVersionSelector ( this ) ;
59+ set => apiVersionSelector = value ;
60+ }
61+
5062 /// <summary>
5163 /// Gets or sets the function used to format the combination of a group name and API version.
5264 /// </summary>
@@ -55,4 +67,13 @@ public IApiVersionParameterSource ApiVersionParameterSource
5567 /// <remarks>The specified callback will only be invoked if a group name has been configured. The API
5668 /// version will be provided formatted according to the <see cref="GroupNameFormat">group name format</see>.</remarks>
5769 public FormatGroupNameCallback ? FormatGroupName { get ; set ; }
70+
71+ private sealed class DefaultApiVersionSelector : IApiVersionSelector
72+ {
73+ private readonly ApiExplorerOptions options ;
74+
75+ public DefaultApiVersionSelector ( ApiExplorerOptions options ) => this . options = options ;
76+
77+ public ApiVersion SelectVersion ( HttpRequest request , ApiVersionModel model ) => options . DefaultApiVersion ;
78+ }
5879}
0 commit comments