3
3
namespace Asp . Versioning . ApiExplorer ;
4
4
5
5
using Asp . Versioning . Routing ;
6
+ using Microsoft . AspNetCore . Http ;
6
7
7
8
/// <content>
8
9
/// Provides additional implementation specific to ASP.NET Core.
@@ -37,7 +38,7 @@ public ApiVersion DefaultApiVersion
37
38
/// <value>The <see cref="IApiVersionParameterSource">API version parameter source</see> used to describe API version parameters.</value>
38
39
public IApiVersionParameterSource ApiVersionParameterSource
39
40
{
40
- get => parameterSource ??= ApiVersionReader . Combine ( new QueryStringApiVersionReader ( ) , new UrlSegmentApiVersionReader ( ) ) ;
41
+ get => parameterSource ??= ApiVersionReader . Default ;
41
42
set => parameterSource = value ;
42
43
}
43
44
@@ -47,6 +48,17 @@ public IApiVersionParameterSource ApiVersionParameterSource
47
48
/// <value>The name associated with the <see cref="ApiVersionRouteConstraint">API version route constraint</see>.</value>
48
49
public string RouteConstraintName { get ; set ; } = string . Empty ;
49
50
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
+
50
62
/// <summary>
51
63
/// Gets or sets the function used to format the combination of a group name and API version.
52
64
/// </summary>
@@ -55,4 +67,13 @@ public IApiVersionParameterSource ApiVersionParameterSource
55
67
/// <remarks>The specified callback will only be invoked if a group name has been configured. The API
56
68
/// version will be provided formatted according to the <see cref="GroupNameFormat">group name format</see>.</remarks>
57
69
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
+ }
58
79
}
0 commit comments