Skip to content

Commit f1adc0c

Browse files
committed
Update to .NET 10 RC1 and OpenAPI 2.0
1 parent d9c8160 commit f1adc0c

File tree

43 files changed

+477
-384
lines changed

Some content is hidden

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

43 files changed

+477
-384
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"jetbrains.resharper.globaltools": {
6-
"version": "2025.2.0",
6+
"version": "2025.2.1",
77
"commands": [
88
"jb"
99
],

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<Nullable>enable</Nullable>
4-
<LangVersion>latest</LangVersion>
4+
<LangVersion>preview</LangVersion>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<IsPackable>false</IsPackable>
77
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
@@ -18,7 +18,7 @@
1818
<PropertyGroup>
1919
<!-- .NET 10 Preview -->
2020
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
21-
<NoWarn>$(NoWarn);NU1903;NU5104;NU1608</NoWarn>
21+
<NoWarn>$(NoWarn);CA1873;NU1903;NU5104;NU1608</NoWarn>
2222
</PropertyGroup>
2323

2424
<PropertyGroup>

package-versions.props

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,15 @@
3636
<PropertyGroup Condition="'$(TargetFramework)' == 'net10.0'">
3737
<!-- Published dependencies (only update on major version change) -->
3838
<EntityFrameworkCoreFrozenVersion>10.0.*-*</EntityFrameworkCoreFrozenVersion>
39+
<SwashbuckleFrozenVersion>10.0.0-pr.3283.*</SwashbuckleFrozenVersion>
3940

4041
<!-- Non-published dependencies (these are safe to update, won't cause a breaking change) -->
4142
<AspNetCoreVersion>10.0.*-*</AspNetCoreVersion>
43+
<SwashbuckleVersion>10.0.0-pr.3283.*</SwashbuckleVersion>
44+
<MicrosoftOpenApiVersion>2.3.*</MicrosoftOpenApiVersion>
45+
<MicrosoftApiServerVersion>10.0.*-*</MicrosoftApiServerVersion>
4246
<EntityFrameworkCoreVersion>10.0.*-*</EntityFrameworkCoreVersion>
43-
<EntityFrameworkCorePomeloVersion>9.0.*-*</EntityFrameworkCorePomeloVersion>
47+
<EntityFrameworkCorePomeloVersion>9.0.*</EntityFrameworkCorePomeloVersion>
4448
</PropertyGroup>
4549

4650
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0'">
@@ -50,6 +54,7 @@
5054
<!-- Non-published dependencies (these are safe to update, won't cause a breaking change) -->
5155
<AspNetCoreVersion>9.0.*</AspNetCoreVersion>
5256
<EntityFrameworkCoreVersion>9.0.*</EntityFrameworkCoreVersion>
57+
<EntityFrameworkCorePomeloVersion>9.0.*</EntityFrameworkCorePomeloVersion>
5358
</PropertyGroup>
5459

5560
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
@@ -59,5 +64,6 @@
5964
<!-- Non-published dependencies (these are safe to update, won't cause a breaking change) -->
6065
<AspNetCoreVersion>8.0.*</AspNetCoreVersion>
6166
<EntityFrameworkCoreVersion>8.0.*</EntityFrameworkCoreVersion>
67+
<EntityFrameworkCorePomeloVersion>8.0.*</EntityFrameworkCorePomeloVersion>
6268
</PropertyGroup>
6369
</Project>

src/Examples/DapperExample/DapperExample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="$(EntityFrameworkCoreVersion)" />
1818
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(EntityFrameworkCoreVersion)" />
1919
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(EntityFrameworkCoreVersion)" />
20-
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="$(EntityFrameworkCoreVersion)" />
20+
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="$(EntityFrameworkCorePomeloVersion)" />
2121
</ItemGroup>
2222
</Project>

src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFrameworks>net10.0;net9.0;net8.0</TargetFrameworks>
3+
<TargetFrameworks>net10.0</TargetFrameworks>
44
<OpenApiGenerateDocumentsOnBuild>true</OpenApiGenerateDocumentsOnBuild>
55
<OpenApiDocumentsDirectory>GeneratedSwagger</OpenApiDocumentsDirectory>
66
</PropertyGroup>

src/Examples/JsonApiDotNetCoreExample/SetOpenApiServerAtBuildTimeFilter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using JetBrains.Annotations;
2-
using Microsoft.OpenApi.Models;
2+
using Microsoft.OpenApi;
33
using Swashbuckle.AspNetCore.SwaggerGen;
44

55
namespace JsonApiDotNetCoreExample;
@@ -16,6 +16,8 @@ public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
1616
{
1717
if (_httpContextAccessor.HttpContext == null)
1818
{
19+
swaggerDoc.Servers ??= [];
20+
1921
swaggerDoc.Servers.Add(new OpenApiServer
2022
{
2123
Url = "https://localhost:44340"

src/JsonApiDotNetCore.OpenApi.Swashbuckle/ConfigureSwaggerGenOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public void Configure(SwaggerGenOptions options)
7676
options.DocumentFilter<StringEnumOrderingFilter>();
7777
options.DocumentFilter<SetSchemaTypeToObjectDocumentFilter>();
7878
options.DocumentFilter<UnusedComponentSchemaCleaner>();
79+
options.DocumentFilter<RemoveTagsFilter>();
7980
}
8081

8182
private List<Type> SelectDerivedTypes(Type baseType)

src/JsonApiDotNetCore.OpenApi.Swashbuckle/JsonApiDotNetCore.OpenApi.Swashbuckle.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net10.0;net8.0</TargetFrameworks>
3+
<TargetFrameworks>net10.0</TargetFrameworks>
44
<IsPackable>true</IsPackable>
55
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
66
<OpenApiGenerateDocuments>false</OpenApiGenerateDocuments>
@@ -33,6 +33,7 @@
3333
</ItemGroup>
3434

3535
<ItemGroup>
36+
<PackageReference Include="Microsoft.OpenApi" Version="$(MicrosoftOpenApiVersion)" />
3637
<PackageReference Include="SauceControl.InheritDoc" Version="$(InheritDocVersion)" PrivateAssets="All" />
3738
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(SwashbuckleFrozenVersion)" />
3839
</ItemGroup>

src/JsonApiDotNetCore.OpenApi.Swashbuckle/JsonApiSchemaIdSelector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public string GetSchemaId(Type type)
115115

116116
private string ApplySchemaTemplate(string schemaTemplate, ResourceType? resourceType, string? relationshipName, AtomicOperationCode? operationCode)
117117
{
118-
string schemaId = schemaTemplate;
118+
string? schemaId = schemaTemplate;
119119

120120
schemaId = resourceType != null
121121
? schemaId.Replace("[ResourceName]", resourceType.PublicName.Singularize()).Pascalize()
@@ -131,7 +131,7 @@ private string ApplySchemaTemplate(string schemaTemplate, ResourceType? resource
131131
schemaId = schemaId.Replace("[OperationCode]", operationCode.Value.ToString().Pascalize());
132132
}
133133

134-
string pascalCaseSchemaId = schemaId.Pascalize();
134+
string? pascalCaseSchemaId = schemaId.Pascalize();
135135

136136
JsonNamingPolicy? namingPolicy = _options.SerializerOptions.PropertyNamingPolicy;
137137
return namingPolicy != null ? namingPolicy.ConvertName(pascalCaseSchemaId) : pascalCaseSchemaId;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.OpenApi;
2+
3+
namespace JsonApiDotNetCore.OpenApi.Swashbuckle;
4+
5+
internal static class MicrosoftOpenApiCompatibilityExtensions
6+
{
7+
public static void SetNullable(this OpenApiSchema schema, bool nullable)
8+
{
9+
ArgumentNullException.ThrowIfNull(schema);
10+
11+
if (nullable)
12+
{
13+
schema.Type ??= JsonSchemaType.Null;
14+
schema.Type |= JsonSchemaType.Null;
15+
}
16+
else
17+
{
18+
if (schema.Type != null)
19+
{
20+
schema.Type &= ~JsonSchemaType.Null;
21+
}
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)