Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Microsoft.OpenApi 2.x and support OpenAPI v3.1 #59480

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@
<XunitExtensibilityExecutionVersion>$(XunitVersion)</XunitExtensibilityExecutionVersion>
<XUnitRunnerVisualStudioVersion>2.8.2</XUnitRunnerVisualStudioVersion>
<MicrosoftDataSqlClientVersion>5.2.2</MicrosoftDataSqlClientVersion>
<MicrosoftOpenApiVersion>1.6.17</MicrosoftOpenApiVersion>
<MicrosoftOpenApiReadersVersion>1.6.17</MicrosoftOpenApiReadersVersion>
<MicrosoftOpenApiVersion>2.0.0-preview2</MicrosoftOpenApiVersion>
<MicrosoftOpenApiReadersVersion>2.0.0-preview2</MicrosoftOpenApiReadersVersion>
captainsafia marked this conversation as resolved.
Show resolved Hide resolved
<!-- dotnet tool versions (see also auto-updated DotnetEfVersion property). -->
<DotnetDumpVersion>6.0.322601</DotnetDumpVersion>
<DotnetServeVersion>1.10.93</DotnetServeVersion>
Expand Down
17 changes: 17 additions & 0 deletions eng/testing/linker/project.csproj.template
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);Microsoft.AspNetCore.Http.Generated</InterceptorsPreviewNamespaces>
<!-- Ensure individual warnings are shown when publishing -->
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<!-- But ignore the single warn files marked below to suppress their known warnings. -->
<NoWarn>$(NoWarn);IL2104;IL3053</NoWarn>
{AdditionalProperties}
</PropertyGroup>

Expand All @@ -27,4 +29,19 @@
{AdditionalProjectReferences}
</ItemGroup>

<!-- Single warn the following assemblies, which have known warnings, so the warnings can be suppressed for now.
Remove this (and the above NoWarn IL2104) once https://github.com/microsoft/OpenAPI.NET/issues/1875 is addressed. -->
<Target Name="ConfigureTrimming"
BeforeTargets="PrepareForILLink">
<ItemGroup>
<IlcArg Include="--singlewarnassembly:Microsoft.OpenApi" />
</ItemGroup>
<ItemGroup>
<ManagedAssemblyToLink Condition="'%(Filename)' == 'Microsoft.OpenApi'">
<IsTrimmable>true</IsTrimmable>
<TrimmerSingleWarn>true</TrimmerSingleWarn>
</ManagedAssemblyToLink>
</ItemGroup>
</Target>

</Project>

This file was deleted.

8 changes: 4 additions & 4 deletions src/OpenApi/perf/Microbenchmarks/TransformersBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ public void SchemaTransformer_Setup()
{
if (context.JsonTypeInfo.Type == typeof(Todo) && context.ParameterDescription != null)
{
schema.Extensions["x-my-extension"] = new OpenApiString(context.ParameterDescription.Name);
schema.Extensions["x-my-extension"] = new OpenApiAny(context.ParameterDescription.Name);
}
else
{
schema.Extensions["x-my-extension"] = new OpenApiString("response");
schema.Extensions["x-my-extension"] = new OpenApiAny("response");
}
return Task.CompletedTask;
});
Expand Down Expand Up @@ -177,11 +177,11 @@ public Task TransformAsync(OpenApiSchema schema, OpenApiSchemaTransformerContext
{
if (context.JsonTypeInfo.Type == typeof(Todo) && context.ParameterDescription != null)
{
schema.Extensions["x-my-extension"] = new OpenApiString(context.ParameterDescription.Name);
schema.Extensions["x-my-extension"] = new OpenApiAny(context.ParameterDescription.Name);
}
else
{
schema.Extensions["x-my-extension"] = new OpenApiString("response");
schema.Extensions["x-my-extension"] = new OpenApiAny("response");
}
return Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Task TransformAsync(OpenApiSchema schema, OpenApiSchemaTransformerContext
{
if (Uri.TryCreate(configuration["DocumentationBaseUrl"], UriKind.Absolute, out var baseUri))
{
var url = new Uri(baseUri, $"/api/docs/schemas/{Uri.EscapeDataString(schema.Type)}");
var url = new Uri(baseUri, $"/api/docs/schemas/{Uri.EscapeDataString(schema.Type.ToString()!)}");

schema.ExternalDocs = new OpenApiExternalDocs
{
Expand Down
3 changes: 1 addition & 2 deletions src/OpenApi/sample/Transformers/OperationTransformers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.OpenApi;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Models;

Expand All @@ -15,7 +14,7 @@ public static OpenApiOptions AddHeader(this OpenApiOptions options, string heade
return options.AddOperationTransformer((operation, context, cancellationToken) =>
{
var schema = OpenApiTypeMapper.MapTypeToOpenApiPrimitiveType(typeof(string));
schema.Default = new OpenApiString(defaultValue);
schema.Default = defaultValue;
operation.Parameters ??= [];
operation.Parameters.Add(new OpenApiParameter
{
Expand Down
95 changes: 0 additions & 95 deletions src/OpenApi/src/Comparers/ComparerHelpers.cs

This file was deleted.

117 changes: 0 additions & 117 deletions src/OpenApi/src/Comparers/OpenApiAnyComparer.cs

This file was deleted.

Loading
Loading