Skip to content

Commit 61c8013

Browse files
Add RouteConstraintName to ApiExplorerOptions. Related to #812
1 parent ce5c718 commit 61c8013

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/AspNet/WebApi/src/Asp.Versioning.WebApi.ApiExplorer/ApiExplorer/ApiExplorerOptions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Asp.Versioning.ApiExplorer;
44

5+
using Asp.Versioning.Routing;
56
using System.Web.Http;
67

78
/// <content>
@@ -37,4 +38,10 @@ public partial class ApiExplorerOptions
3738
/// </summary>
3839
/// <value>The <see cref="IApiVersionParameterSource">API version parameter source</see> used to describe API version parameters.</value>
3940
public IApiVersionParameterSource ApiVersionParameterSource => options.Value.ApiVersionReader;
41+
42+
/// <summary>
43+
/// Gets the name associated with the API version route constraint.
44+
/// </summary>
45+
/// <value>The name associated with the <see cref="ApiVersionRouteConstraint">API version route constraint</see>.</value>
46+
public string RouteConstraintName => options.Value.RouteConstraintName;
4047
}

src/AspNetCore/WebApi/src/Asp.Versioning.Mvc.ApiExplorer/ApiExplorerOptions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Asp.Versioning.ApiExplorer;
44

5+
using Asp.Versioning.Routing;
6+
57
/// <content>
68
/// Provides additional implementation specific to ASP.NET Core.
79
/// </content>
@@ -38,4 +40,10 @@ public IApiVersionParameterSource ApiVersionParameterSource
3840
get => parameterSource ??= ApiVersionReader.Combine( new QueryStringApiVersionReader(), new UrlSegmentApiVersionReader() );
3941
set => parameterSource = value;
4042
}
43+
44+
/// <summary>
45+
/// Gets or sets the name associated with the API version route constraint.
46+
/// </summary>
47+
/// <value>The name associated with the <see cref="ApiVersionRouteConstraint">API version route constraint</see>.</value>
48+
public string RouteConstraintName { get; set; } = string.Empty;
4149
}

src/AspNetCore/WebApi/src/Asp.Versioning.Mvc.ApiExplorer/ApiExplorerOptionsFactory{T}.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ public virtual T Create( string name )
5959
var apiVersioningOptions = Options;
6060
var options = new T()
6161
{
62-
DefaultApiVersion = apiVersioningOptions.DefaultApiVersion,
63-
ApiVersionParameterSource = apiVersioningOptions.ApiVersionReader,
6462
AssumeDefaultVersionWhenUnspecified = apiVersioningOptions.AssumeDefaultVersionWhenUnspecified,
63+
ApiVersionParameterSource = apiVersioningOptions.ApiVersionReader,
64+
DefaultApiVersion = apiVersioningOptions.DefaultApiVersion,
65+
RouteConstraintName = apiVersioningOptions.RouteConstraintName,
6566
};
6667

6768
foreach ( var setup in Setups )

0 commit comments

Comments
 (0)