Skip to content

Commit 0e0092f

Browse files
author
Chris Martinez
committed
Revert "Code clean up"
This reverts commit 0d1b9fa.
1 parent 0d1b9fa commit 0e0092f

File tree

5 files changed

+14
-24
lines changed

5 files changed

+14
-24
lines changed

examples/AspNetCore/OData/ODataOpenApiExample/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
.AddOData(
1717
options =>
1818
{
19-
options.Count().Select().OrderBy().SetMaxTop( 3 );
19+
options.Count().Select().OrderBy();
2020
options.RouteOptions.EnableKeyInParenthesis = false;
2121
options.RouteOptions.EnableNonParenthesisForEmptyParameterFunction = true;
2222
options.RouteOptions.EnablePropertyNameCaseInsensitive = true;

examples/AspNetCore/OData/ODataOpenApiExample/V3/SuppliersController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ public class SuppliersController : ODataController
2929
/// <returns>All available suppliers.</returns>
3030
/// <response code="200">Suppliers successfully retrieved.</response>
3131
[HttpGet]
32-
//[EnableQuery]
33-
[EnableQuery( MaxTop = 2 )]
32+
[EnableQuery]
3433
[Produces( "application/json" )]
3534
[ProducesResponseType( typeof( ODataValue<IEnumerable<Supplier>> ), Status200OK )]
3635
public IQueryable<Supplier> Get() => suppliers;

examples/AspNetCore/WebApi/MinimalOpenApiExample/MinimalOpenApiExample.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.0" />
98
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0-*" />
109
</ItemGroup>
1110

examples/AspNetCore/WebApi/MinimalOpenApiExample/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
.HasApiVersion( 1.0 );
5757

5858
ordersV1.MapGet( "/{id:int}", ( int id ) => new OrderV1() { Id = id, Customer = "John Doe" } )
59-
.WithOpenApi()
6059
.Produces<OrderV1>()
6160
.Produces( 404 );
6261

src/AspNetCore/WebApi/src/Asp.Versioning.Http/ApiVersioningFeature.cs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace Asp.Versioning;
55
using Microsoft.AspNetCore.Http;
66
using Microsoft.Extensions.DependencyInjection;
77
using System.Globalization;
8-
using System.Runtime.CompilerServices;
98

109
/// <summary>
1110
/// Represents the API versioning feature.
@@ -34,10 +33,11 @@ public IReadOnlyList<string> RawRequestedApiVersions
3433
{
3534
if ( rawApiVersions is null )
3635
{
37-
var reader = context.RequestServices.GetService<IApiVersionReader>()
38-
?? ApiVersionReader.Combine(
39-
new QueryStringApiVersionReader(),
40-
new UrlSegmentApiVersionReader() );
36+
var reader =
37+
context.RequestServices.GetService<IApiVersionReader>() ??
38+
ApiVersionReader.Combine(
39+
new QueryStringApiVersionReader(),
40+
new UrlSegmentApiVersionReader() );
4141

4242
rawApiVersions = reader.Read( context.Request );
4343
}
@@ -58,7 +58,11 @@ public string? RawRequestedApiVersion
5858
{
5959
0 => default,
6060
1 => values[0],
61-
_ => throw NewAmbiguousApiVersionException( values ),
61+
#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations; existing behavior via IApiVersionReader.Read
62+
_ => throw new AmbiguousApiVersionException(
63+
string.Format( CultureInfo.CurrentCulture, CommonSR.MultipleDifferentApiVersionsRequested, string.Join( ", ", values ) ),
64+
values ),
65+
#pragma warning restore CA1065
6266
};
6367
}
6468
set
@@ -84,8 +88,7 @@ public ApiVersion? RequestedApiVersion
8488
return apiVersion;
8589
}
8690

87-
var parser = context.RequestServices.GetService<IApiVersionParser>()
88-
?? ApiVersionParser.Default;
91+
var parser = context.RequestServices.GetRequiredService<IApiVersionParser>();
8992

9093
try
9194
{
@@ -102,20 +105,10 @@ public ApiVersion? RequestedApiVersion
102105
{
103106
apiVersion = value;
104107

105-
if ( apiVersion is not null &&
106-
( rawApiVersions is null || rawApiVersions.Count == 0 ) )
108+
if ( apiVersion is not null && ( rawApiVersions is null || rawApiVersions.Count == 0 ) )
107109
{
108110
rawApiVersions = new[] { apiVersion.ToString() };
109111
}
110112
}
111113
}
112-
113-
[MethodImpl( MethodImplOptions.AggressiveInlining )]
114-
private static AmbiguousApiVersionException NewAmbiguousApiVersionException( IReadOnlyList<string> values ) =>
115-
new(
116-
string.Format(
117-
CultureInfo.CurrentCulture,
118-
CommonSR.MultipleDifferentApiVersionsRequested,
119-
string.Join( ", ", values.ToArray(), 0, values.Count ) ),
120-
values );
121114
}

0 commit comments

Comments
 (0)