ServiceModel.Grpc.AspNetCore.NSwag
1.9.1
See the version list below for details.
dotnet add package ServiceModel.Grpc.AspNetCore.NSwag --version 1.9.1
NuGet\Install-Package ServiceModel.Grpc.AspNetCore.NSwag -Version 1.9.1
<PackageReference Include="ServiceModel.Grpc.AspNetCore.NSwag" Version="1.9.1" />
paket add ServiceModel.Grpc.AspNetCore.NSwag --version 1.9.1
#r "nuget: ServiceModel.Grpc.AspNetCore.NSwag, 1.9.1"
// Install ServiceModel.Grpc.AspNetCore.NSwag as a Cake Addin #addin nuget:?package=ServiceModel.Grpc.AspNetCore.NSwag&version=1.9.1 // Install ServiceModel.Grpc.AspNetCore.NSwag as a Cake Tool #tool nuget:?package=ServiceModel.Grpc.AspNetCore.NSwag&version=1.9.1
ServiceModel.Grpc.AspNetCore.NSwag
ServiceModel.Grpc
enables applications to communicate with gRPC services using a code-first approach (no .proto files), helps to get around limitations of gRPC protocol like "only reference types", "exact one input", "no nulls", "no value-types". Provides exception handling. Helps to migrate existing WCF solution to gRPC with minimum effort.
ServiceModel.Grpc.AspNetCore.NSwag
is package with NSwag integration for ServiceModel.Grpc.AspNetCore.
Declare a service contract and implement service
A service contract is an interface decorated with the ServiceContract
attribute. Interface methods decorated with the OperationContract
attribute are treated as gRPC operations.
For example, following ICalculator
contract with unary Sum
operation and client streaming MultiplyBy
operation:
[ServiceContract]
public interface ICalculator
{
[OperationContract]
Task<long> Sum(long x, int y, int z, CancellationToken token = default);
[OperationContract]
ValueTask<(int Multiplier, IAsyncEnumerable<int> Values)> MultiplyBy(IAsyncEnumerable<int> values, int multiplier, CancellationToken token = default);
}
internal sealed class Calculator : ICalculator
{
public Task<long> Sum(long x, int y, int z, CancellationToken token)
{
...
}
public ValueTask<(int Multiplier, IAsyncEnumerable<int> Values)> MultiplyBy(IAsyncEnumerable<int> values, int multiplier, CancellationToken token)
{
...
}
}
Configure NSwag
Enable ServiceModel.Grpc code-first and NSwag integration, add service to the routing pipeline.
var builder = WebApplication.CreateBuilder();
// NSwag.AspNetCore
builder.Services.AddMvc();
builder.Services.AddOpenApiDocument(settings =>
{
settings.DocumentName = "v1";
settings.Title = "My API";
settings.Version = "1.0";
});
// enable ServiceModel.Grpc code-first
builder.Services.AddServiceModelGrpc(options => { ... });
// enable ServiceModel.Grpc integration for NSwag.AspNetCore
builder.Services.AddServiceModelGrpcSwagger();
var app = builder.Build();
// NSwag.AspNetCore
app.UseOpenApi();
app.UseSwaggerUi();
app.UseReDoc();
// Enable ServiceModel.Grpc HTTP/1.1 JSON gateway for Swagger UI, button "Try it out"
app.UseServiceModelGrpcSwaggerGateway();
// bind the service
app.MapGrpcService<Calculator>();
app.Run();
Links
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- NSwag.AspNetCore (>= 14.1.0)
- ServiceModel.Grpc.AspNetCore (>= 1.9.1)
-
net7.0
- NSwag.AspNetCore (>= 14.1.0)
- ServiceModel.Grpc.AspNetCore (>= 1.9.1)
-
net8.0
- NSwag.AspNetCore (>= 14.1.0)
- ServiceModel.Grpc.AspNetCore (>= 1.9.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ServiceModel.Grpc.AspNetCore.NSwag:
Package | Downloads |
---|---|
MF40.Silo
Orleans Silo |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.11.0 | 56 | 11/23/2024 |
1.10.1 | 113 | 10/19/2024 |
1.9.1 | 125 | 9/29/2024 |
1.9.0 | 173 | 7/21/2024 |
1.8.3 | 248 | 5/18/2024 |
1.8.2 | 249 | 3/2/2024 |
1.8.1 | 240 | 2/13/2024 |
1.8.0 | 188 | 1/7/2024 |
1.7.0 | 142 | 12/24/2023 |
1.6.1 | 205 | 11/25/2023 |
1.6.0 | 381 | 9/9/2023 |
1.5.2 | 575 | 6/25/2023 |
1.5.1 | 439 | 5/1/2023 |
1.5.0 | 294 | 3/7/2023 |
1.4.13 | 325 | 12/19/2022 |
1.4.12 | 366 | 11/19/2022 |
1.4.11 | 402 | 10/23/2022 |
1.4.10 | 998 | 8/14/2022 |
1.4.9 | 448 | 7/23/2022 |
1.4.8 | 566 | 5/29/2022 |
1.4.7 | 499 | 5/21/2022 |
1.4.6 | 1,700 | 4/3/2022 |
1.4.5 | 529 | 3/26/2022 |
1.4.4 | 563 | 3/12/2022 |
1.4.3 | 602 | 2/5/2022 |
1.4.2 | 625 | 1/22/2022 |
1.4.1 | 465 | 1/8/2022 |
1.4.0 | 2,456 | 11/26/2021 |
1.3.2 | 402 | 11/5/2021 |
1.3.1 | 472 | 10/10/2021 |
1.3.0 | 407 | 7/31/2021 |
1.2.1 | 383 | 6/12/2021 |