Skip to content

Commit 51343cb

Browse files
.NET 10 preparation
Cherry-pick refactoring from #3283 to make multi-targeting easier for ASP.NET Core 10 and Microsoft.OpenApi v2.
1 parent 48c2982 commit 51343cb

75 files changed

Lines changed: 1386 additions & 1137 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<ItemGroup Condition=" '$(PackageReadmeFile)' != '' ">
5959
<None Include="$(MSBuildThisFileDirectory)$(PackageReadmeFile)" Pack="True" PackagePath="" />
6060
</ItemGroup>
61-
<PropertyGroup Condition=" '$(SignAssembly)' == 'true' AND '$(OS)' != 'Windows_NT' ">
61+
<PropertyGroup Condition=" '$(SignAssembly)' == 'true' AND '$(OS)' != !$([MSBuild]::IsOSPlatform('Windows')) ">
6262
<PublicSign>true</PublicSign>
6363
</PropertyGroup>
6464
<PropertyGroup>

perf/Swashbuckle.AspNetCore.Benchmarks/Swashbuckle.AspNetCore.Benchmarks.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net8.0</TargetFramework>
66
</PropertyGroup>
7+
<ItemGroup>
8+
<Compile Include="..\..\src\Shared\JsonSchemaTypes.cs" Link="JsonSchemaTypes.cs" />
9+
</ItemGroup>
710
<ItemGroup>
811
<ProjectReference Include="..\..\src\Swashbuckle.AspNetCore.Annotations\Swashbuckle.AspNetCore.Annotations.csproj" />
912
<ProjectReference Include="..\..\src\Swashbuckle.AspNetCore.SwaggerGen\Swashbuckle.AspNetCore.SwaggerGen.csproj" />

perf/Swashbuckle.AspNetCore.Benchmarks/XmlCommentsBenchmark.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void Setup()
101101
{
102102
Schema = new()
103103
{
104-
Type = "string",
104+
Type = JsonSchemaTypes.String,
105105
Description = "schema-level description",
106106
},
107107
};
@@ -120,7 +120,7 @@ public void Setup()
120120
{
121121
Schema = new()
122122
{
123-
Type = "string",
123+
Type = JsonSchemaTypes.String,
124124
},
125125
},
126126
},

src/Shared/JsonSchemaTypes.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Swashbuckle.AspNetCore;
2+
3+
internal static class JsonSchemaTypes
4+
{
5+
public const string Array = "array";
6+
public const string Boolean = "boolean";
7+
public const string Integer = "integer";
8+
public const string Number = "number";
9+
public const string Null = "null";
10+
public const string Object = "object";
11+
public const string String = "string";
12+
}

src/Swashbuckle.AspNetCore.Annotations/AnnotationsOperationFilter.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ public class AnnotationsOperationFilter : IOperationFilter
1010
{
1111
public void Apply(OpenApiOperation operation, OperationFilterContext context)
1212
{
13-
IEnumerable<object> controllerAttributes = Array.Empty<object>();
14-
IEnumerable<object> actionAttributes = Array.Empty<object>();
15-
IEnumerable<object> metadataAttributes = Array.Empty<object>();
13+
IEnumerable<object> controllerAttributes = [];
14+
IEnumerable<object> actionAttributes = [];
15+
IEnumerable<object> metadataAttributes = [];
1616

1717
if (context.MethodInfo != null)
1818
{
@@ -65,9 +65,7 @@ private static void ApplySwaggerOperationAttribute(
6565

6666
if (swaggerOperationAttribute.Tags != null)
6767
{
68-
operation.Tags = swaggerOperationAttribute.Tags
69-
.Select(tagName => new OpenApiTag { Name = tagName })
70-
.ToList();
68+
operation.Tags = [.. swaggerOperationAttribute.Tags.Select(tagName => new OpenApiTag { Name = tagName })];
7169
}
7270
}
7371

@@ -86,7 +84,7 @@ public static void ApplySwaggerOperationFilterAttributes(
8684
}
8785
}
8886

89-
private void ApplySwaggerResponseAttributes(
87+
private static void ApplySwaggerResponseAttributes(
9088
OpenApiOperation operation,
9189
OperationFilterContext context,
9290
IEnumerable<object> controllerAndActionAttributes)
@@ -97,10 +95,7 @@ private void ApplySwaggerResponseAttributes(
9795
{
9896
var statusCode = swaggerResponseAttribute.StatusCode.ToString();
9997

100-
if (operation.Responses == null)
101-
{
102-
operation.Responses = new OpenApiResponses();
103-
}
98+
operation.Responses ??= [];
10499

105100
if (!operation.Responses.TryGetValue(statusCode, out OpenApiResponse response))
106101
{

src/Swashbuckle.AspNetCore.Annotations/PublicAPI/PublicAPI.Shipped.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ Swashbuckle.AspNetCore.Annotations.SwaggerRequestBodyAttribute.SwaggerRequestBod
4949
Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute
5050
Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.ContentTypes.get -> string[]
5151
Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.ContentTypes.set -> void
52-
Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.get -> string
53-
Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.set -> void
5452
Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.SwaggerResponseAttribute(int statusCode, string description = null, System.Type type = null) -> void
5553
Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.SwaggerResponseAttribute(int statusCode, string description = null, System.Type type = null, params string[] contentTypes) -> void
5654
Swashbuckle.AspNetCore.Annotations.SwaggerSchemaAttribute
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.get -> string
2+
Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.set -> void

src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net6.0/PublicAPI.Unshipped.txt

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.get -> string
2+
Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.set -> void

src/Swashbuckle.AspNetCore.Annotations/PublicAPI/net8.0/PublicAPI.Unshipped.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)