Skip to content

Commit 482c5e4

Browse files
committed
Merge branch 'main' of github.com:dotnet/aspnetcore into sfx-aspnetcore
2 parents ba90cf1 + 5278d28 commit 482c5e4

File tree

9 files changed

+60
-28
lines changed

9 files changed

+60
-28
lines changed

eng/helix/helix.proj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
<!-- Specify the .NET runtime we need which will be included as a correlation payload. -->
5353
<ItemGroup>
5454
<!--
55-
Use the BrowserDebugHost transport package as a sentinel for the non-shipping version of the NETCoreApp shared framework.
55+
Use the Microsoft.Internal.Runtime.AspNetCore.Transport transport package as a sentinel for the non-shipping version of the NETCoreApp shared framework.
5656
-->
57-
<AdditionalDotNetPackage Include="$(MicrosoftNETCoreBrowserDebugHostTransportVersion)">
57+
<AdditionalDotNetPackage Include="$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)">
5858
<PackageType>runtime</PackageType>
5959
</AdditionalDotNetPackage>
6060

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"dotnet": "10.0.100-alpha.1.24510.13",
77
"runtimes": {
88
"dotnet/x86": [
9-
"$(MicrosoftNETCoreBrowserDebugHostTransportVersion)"
9+
"$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)"
1010
],
1111
"dotnet": [
12-
"$(MicrosoftNETCoreBrowserDebugHostTransportVersion)"
12+
"$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)"
1313
]
1414
},
1515
"vs": {

src/Framework/App.Runtime/src/aspnetcore-runtime-composite.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<PropertyGroup>
2828
<!-- Use the BrowserDebugHost as a sentinel for the nonshipping version for .NETCoreApp -->
2929
<DotNetRuntimeArchiveFileName>dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-$(TargetRuntimeIdentifier).$(ArchiveFormat)</DotNetRuntimeArchiveFileName>
30-
<DotNetRuntimeDownloadPath>Runtime/$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/$(DotNetRuntimeArchiveFileName)</DotNetRuntimeDownloadPath>
30+
<DotNetRuntimeDownloadPath>Runtime/$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)/$(DotNetRuntimeArchiveFileName)</DotNetRuntimeDownloadPath>
3131
<DotNetRuntimeArchive>$(BaseIntermediateOutputPath)$(DotNetRuntimeArchiveFileName)</DotNetRuntimeArchive>
3232
</PropertyGroup>
3333

src/Framework/App.Runtime/src/aspnetcore-runtime.proj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
Download the Microsoft.NETCore.App.Runtime layout.
2929
-->
3030
<PropertyGroup>
31-
<!-- Use the BrowserDebugHost as a sentinel for the nonshipping version for .NETCoreApp -->
31+
<!-- Use the Microsoft.Internal.Runtime.AspNetCore.Transport package as a sentinel for the nonshipping version for .NETCoreApp -->
3232
<DotNetRuntimeArchiveFileName>dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-$(TargetRuntimeIdentifier).$(ArchiveFormat)</DotNetRuntimeArchiveFileName>
33-
<DotNetRuntimeDownloadPath>Runtime/$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/$(DotNetRuntimeArchiveFileName)</DotNetRuntimeDownloadPath>
33+
<DotNetRuntimeDownloadPath>Runtime/$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)/$(DotNetRuntimeArchiveFileName)</DotNetRuntimeDownloadPath>
3434
<DotNetRuntimeArchive>$(BaseIntermediateOutputPath)$(DotNetRuntimeArchiveFileName)</DotNetRuntimeArchive>
3535
</PropertyGroup>
3636

src/Installers/Windows/WindowsHostingBundle/Product.targets

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,31 @@
4343
<Target Name="CollectDependencies" BeforeTargets="Restore;CollectPackageReferences">
4444
<!-- Use the BrowserDebugHost as a sentinel for the nonshipping version for NETCoreApp. -->
4545
<ItemGroup>
46-
<RemoteAsset Include="$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.msi">
46+
<RemoteAsset Include="$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)/dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.msi">
4747
<TargetFileName>dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.msi</TargetFileName>
4848
</RemoteAsset>
49-
<RemoteAsset Include="$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.msi">
49+
<RemoteAsset Include="$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)/dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.msi">
5050
<TargetFileName>dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.msi</TargetFileName>
5151
</RemoteAsset>
52-
<RemoteAsset Include="$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.msi">
52+
<RemoteAsset Include="$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)/dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.msi">
5353
<TargetFileName>dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.msi</TargetFileName>
5454
</RemoteAsset>
55-
<RemoteAsset Include="$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-host-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.msi">
55+
<RemoteAsset Include="$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)/dotnet-host-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.msi">
5656
<TargetFileName>dotnet-host-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.msi</TargetFileName>
5757
</RemoteAsset>
58-
<RemoteAsset Include="$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-host-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.msi">
58+
<RemoteAsset Include="$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)/dotnet-host-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.msi">
5959
<TargetFileName>dotnet-host-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.msi</TargetFileName>
6060
</RemoteAsset>
61-
<RemoteAsset Include="$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-host-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.msi">
61+
<RemoteAsset Include="$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)/dotnet-host-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.msi">
6262
<TargetFileName>dotnet-host-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.msi</TargetFileName>
6363
</RemoteAsset>
64-
<RemoteAsset Include="$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-hostfxr-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.msi">
64+
<RemoteAsset Include="$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)/dotnet-hostfxr-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.msi">
6565
<TargetFileName>dotnet-hostfxr-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.msi</TargetFileName>
6666
</RemoteAsset>
67-
<RemoteAsset Include="$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-hostfxr-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.msi">
67+
<RemoteAsset Include="$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)/dotnet-hostfxr-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.msi">
6868
<TargetFileName>dotnet-hostfxr-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.msi</TargetFileName>
6969
</RemoteAsset>
70-
<RemoteAsset Include="$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-hostfxr-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.msi">
70+
<RemoteAsset Include="$(MicrosoftInternalRuntimeAspNetCoreTransportVersion)/dotnet-hostfxr-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.msi">
7171
<TargetFileName>dotnet-hostfxr-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.msi</TargetFileName>
7272
</RemoteAsset>
7373
</ItemGroup>

src/OpenApi/sample/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
var app = builder.Build();
3838

3939
app.MapOpenApi();
40+
app.MapOpenApi("/openapi/{documentName}.yaml");
4041
if (app.Environment.IsDevelopment())
4142
{
4243
app.MapSwaggerUi();

src/OpenApi/src/Extensions/OpenApiEndpointRouteBuilderExtensions.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,16 @@ public static IEndpointConventionBuilder MapOpenApi(this IEndpointRouteBuilder e
4949
using var writer = Utf8BufferTextWriter.Get(output);
5050
try
5151
{
52-
document.Serialize(new OpenApiJsonWriter(writer), documentOptions.OpenApiVersion);
53-
context.Response.ContentType = "application/json;charset=utf-8";
52+
if (UseYaml(pattern))
53+
{
54+
document.Serialize(new OpenApiYamlWriter(writer), documentOptions.OpenApiVersion);
55+
context.Response.ContentType = "text/plain+yaml;charset=utf-8";
56+
}
57+
else
58+
{
59+
document.Serialize(new OpenApiJsonWriter(writer), documentOptions.OpenApiVersion);
60+
context.Response.ContentType = "application/json;charset=utf-8";
61+
}
5462
await context.Response.BodyWriter.WriteAsync(output.ToArray(), context.RequestAborted);
5563
await context.Response.BodyWriter.FlushAsync(context.RequestAborted);
5664
}
@@ -63,4 +71,8 @@ public static IEndpointConventionBuilder MapOpenApi(this IEndpointRouteBuilder e
6371
}
6472
}).ExcludeFromDescription();
6573
}
74+
75+
private static bool UseYaml(string pattern) =>
76+
pattern.EndsWith(".yaml", StringComparison.OrdinalIgnoreCase) ||
77+
pattern.EndsWith(".yml", StringComparison.OrdinalIgnoreCase);
6678
}

src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiEndpointRouteBuilderExtensionsTests.cs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ public void MapOpenApi_ReturnsEndpointConventionBuilder()
2929
Assert.IsAssignableFrom<IEndpointConventionBuilder>(returnedBuilder);
3030
}
3131

32-
[Fact]
33-
public void MapOpenApi_SupportsCustomizingPath()
32+
[Theory]
33+
[InlineData("/custom/{documentName}/openapi.json")]
34+
[InlineData("/custom/{documentName}/openapi.yaml")]
35+
[InlineData("/custom/{documentName}/openapi.yml")]
36+
public void MapOpenApi_SupportsCustomizingPath(string expectedPath)
3437
{
3538
// Arrange
36-
var expectedPath = "/custom/{documentName}/openapi.json";
3739
var serviceProvider = CreateServiceProvider();
3840
var builder = new DefaultEndpointRouteBuilder(new ApplicationBuilder(serviceProvider));
3941

@@ -72,13 +74,17 @@ public async Task MapOpenApi_ReturnsRenderedDocument()
7274
});
7375
}
7476

75-
[Fact]
76-
public async Task MapOpenApi_ReturnsDefaultDocumentIfNoNameProvided()
77+
[Theory]
78+
[InlineData("/openapi.json", "application/json;charset=utf-8", false)]
79+
[InlineData("/openapi.toml", "application/json;charset=utf-8", false)]
80+
[InlineData("/openapi.yaml", "text/plain+yaml;charset=utf-8", true)]
81+
[InlineData("/openapi.yml", "text/plain+yaml;charset=utf-8", true)]
82+
public async Task MapOpenApi_ReturnsDefaultDocumentIfNoNameProvided(string expectedPath, string expectedContentType, bool isYaml)
7783
{
7884
// Arrange
7985
var serviceProvider = CreateServiceProvider();
8086
var builder = new DefaultEndpointRouteBuilder(new ApplicationBuilder(serviceProvider));
81-
builder.MapOpenApi("/openapi.json");
87+
builder.MapOpenApi(expectedPath);
8288
var context = new DefaultHttpContext();
8389
var responseBodyStream = new MemoryStream();
8490
context.Response.Body = responseBodyStream;
@@ -91,6 +97,11 @@ public async Task MapOpenApi_ReturnsDefaultDocumentIfNoNameProvided()
9197

9298
// Assert
9399
Assert.Equal(StatusCodes.Status200OK, context.Response.StatusCode);
100+
Assert.Equal(expectedContentType, context.Response.ContentType);
101+
var responseString = Encoding.UTF8.GetString(responseBodyStream.ToArray());
102+
// String check to validate that generated document starts with YAML syntax
103+
Assert.Equal(isYaml, responseString.StartsWith("openapi: 3.0.1", StringComparison.OrdinalIgnoreCase));
104+
responseBodyStream.Position = 0;
94105
ValidateOpenApiDocument(responseBodyStream, document =>
95106
{
96107
Assert.Equal("OpenApiEndpointRouteBuilderExtensionsTests | v1", document.Info.Title);
@@ -121,16 +132,19 @@ public async Task MapOpenApi_Returns404ForUnresolvedDocument()
121132
Assert.Equal("No OpenAPI document with the name 'v2' was found.", Encoding.UTF8.GetString(responseBodyStream.ToArray()));
122133
}
123134

124-
[Fact]
125-
public async Task MapOpenApi_ReturnsDocumentIfNameProvidedInQuery()
135+
[Theory]
136+
[InlineData("/openapi.json", "application/json;charset=utf-8", false)]
137+
[InlineData("/openapi.yaml", "text/plain+yaml;charset=utf-8", true)]
138+
[InlineData("/openapi.yml", "text/plain+yaml;charset=utf-8", true)]
139+
public async Task MapOpenApi_ReturnsDocumentIfNameProvidedInQuery(string expectedPath, string expectedContentType, bool isYaml)
126140
{
127141
// Arrange
128142
var documentName = "v2";
129143
var hostEnvironment = new HostEnvironment() { ApplicationName = nameof(OpenApiEndpointRouteBuilderExtensionsTests) };
130144
var serviceProviderIsService = new ServiceProviderIsService();
131145
var serviceProvider = CreateServiceProvider(documentName);
132146
var builder = new DefaultEndpointRouteBuilder(new ApplicationBuilder(serviceProvider));
133-
builder.MapOpenApi("/openapi.json");
147+
builder.MapOpenApi(expectedPath);
134148
var context = new DefaultHttpContext();
135149
var responseBodyStream = new MemoryStream();
136150
context.Response.Body = responseBodyStream;
@@ -144,6 +158,11 @@ public async Task MapOpenApi_ReturnsDocumentIfNameProvidedInQuery()
144158

145159
// Assert
146160
Assert.Equal(StatusCodes.Status200OK, context.Response.StatusCode);
161+
Assert.Equal(expectedContentType, context.Response.ContentType);
162+
var responseString = Encoding.UTF8.GetString(responseBodyStream.ToArray());
163+
// String check to validate that generated document starts with YAML syntax
164+
Assert.Equal(isYaml, responseString.StartsWith("openapi: 3.0.1", StringComparison.OrdinalIgnoreCase));
165+
responseBodyStream.Position = 0;
147166
ValidateOpenApiDocument(responseBodyStream, document =>
148167
{
149168
Assert.Equal($"OpenApiEndpointRouteBuilderExtensionsTests | {documentName}", document.Info.Title);

0 commit comments

Comments
 (0)