Skip to content

Commit 744644e

Browse files
committed
update to net6.0
1 parent 5640ae6 commit 744644e

File tree

5 files changed

+13
-21
lines changed

5 files changed

+13
-21
lines changed

build/version.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<GrpcHttpApiPackageVersion>1.0.0</GrpcHttpApiPackageVersion>
3+
<GrpcHttpApiPackageVersion>1.1.0</GrpcHttpApiPackageVersion>
44
</PropertyGroup>
55
</Project>

sample/Grpc.HttpApi.Sample/Grape.Grpc.HttpApi.Sample.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
</PropertyGroup>
77

src/Grape.Grpc.HttpApi/Grape.Grpc.HttpApi.csproj

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Import Project="../../build/version.props" />
33
<Import Project="../../build/releasenotes.props" />
44
<PropertyGroup>
5-
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
5+
<TargetFramework>net6.0</TargetFramework>
66

77
<Description>Implement Grpc interface conversion layer HttpApi interface</Description>
88
<Copyright>Xuanye @ 2021</Copyright>
@@ -24,14 +24,13 @@
2424
</PropertyGroup>
2525

2626
<ItemGroup>
27-
<PackageReference Include="Google.Protobuf" Version="3.17.3" />
28-
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.34.0" />
29-
<PackageReference Include="Grpc.Tools" Version="2.34.0">
27+
<PackageReference Include="Google.Protobuf" Version="3.27.1" />
28+
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.63.0" />
29+
<PackageReference Include="Grpc.Tools" Version="2.64.0">
3030
<PrivateAssets>all</PrivateAssets>
3131
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3232
</PackageReference>
33-
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
34-
<PackageReference Include="Microsoft.OpenApi" Version="1.2.3" />
33+
<PackageReference Include="Microsoft.OpenApi" Version="1.6.14" />
3534
</ItemGroup>
3635
<ItemGroup>
3736
<Protobuf Include="Protos\**\*.proto" ProtoRoot="Protos" GrpcServices="Both" />

src/Grape.Grpc.HttpApi/Swagger/SwaggerMiddleware.cs

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Microsoft.AspNetCore.Http;
22
using Microsoft.Extensions.Logging;
33
using System;
4-
using System.Globalization;
54
using System.IO;
65
using System.Text;
76
using System.Threading.Tasks;
@@ -16,7 +15,7 @@ public class SwaggerMiddleware
1615

1716
public SwaggerMiddleware(
1817
SwaggerOptions options,
19-
RequestDelegate next,
18+
RequestDelegate next,
2019
ILogger<SwaggerMiddleware> logger
2120
)
2221
{
@@ -38,17 +37,16 @@ public async Task Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvid
3837
var swagger = swaggerProvider.GetSwaggerInfo();
3938
await RespondWithSwaggerJson(httpContext.Response, swagger);
4039
}
41-
catch(Exception ex)
40+
catch (Exception ex)
4241
{
4342
_logger.LogError(ex, ex.Message);
4443
RespondWithNotFound(httpContext.Response);
4544
}
46-
4745
}
4846

4947
private bool RequestingSwaggerDocument(HttpRequest request)
5048
{
51-
if(!string.Equals(request.Method, "get", StringComparison.OrdinalIgnoreCase))
49+
if (!string.Equals(request.Method, "get", StringComparison.OrdinalIgnoreCase))
5250
{
5351
return false;
5452
}
@@ -66,14 +64,9 @@ private async Task RespondWithSwaggerJson(HttpResponse response, SwaggerInfo swa
6664
response.StatusCode = 200;
6765
response.ContentType = "application/json;charset=utf-8";
6866

69-
var settings = new Newtonsoft.Json.JsonSerializerSettings
70-
{
71-
DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore
72-
};
67+
var swaggerJson = System.Text.Json.JsonSerializer.Serialize(swagger, new System.Text.Json.JsonSerializerOptions(System.Text.Json.JsonSerializerDefaults.Web));
7368

74-
var swaggerJson = Newtonsoft.Json.JsonConvert.SerializeObject(swagger, Newtonsoft.Json.Formatting.None, settings);
7569
await response.WriteAsync(swaggerJson, new UTF8Encoding(false));
7670
}
7771
}
78-
79-
}
72+
}

tests/Grape.Grpc.HttpApi.UnitTests/Grape.Grpc.HttpApi.UnitTests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
4+
<TargetFrameworks>net6.0</TargetFrameworks>
55

66
<IsPackable>false</IsPackable>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>

0 commit comments

Comments
 (0)