ServiceModel.Grpc.AspNetCore.Swashbuckle 1.13.0

dotnet add package ServiceModel.Grpc.AspNetCore.Swashbuckle --version 1.13.0
                    
NuGet\Install-Package ServiceModel.Grpc.AspNetCore.Swashbuckle -Version 1.13.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ServiceModel.Grpc.AspNetCore.Swashbuckle" Version="1.13.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ServiceModel.Grpc.AspNetCore.Swashbuckle" Version="1.13.0" />
                    
Directory.Packages.props
<PackageReference Include="ServiceModel.Grpc.AspNetCore.Swashbuckle" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ServiceModel.Grpc.AspNetCore.Swashbuckle --version 1.13.0
                    
#r "nuget: ServiceModel.Grpc.AspNetCore.Swashbuckle, 1.13.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ServiceModel.Grpc.AspNetCore.Swashbuckle&version=1.13.0
                    
Install ServiceModel.Grpc.AspNetCore.Swashbuckle as a Cake Addin
#tool nuget:?package=ServiceModel.Grpc.AspNetCore.Swashbuckle&version=1.13.0
                    
Install ServiceModel.Grpc.AspNetCore.Swashbuckle as a Cake Tool

ServiceModel.Grpc.AspNetCore.Swashbuckle

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.Swashbuckle is package with Swashbuckle.AspNetCore 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 Swashbuckle.AspNetCore

Enable ServiceModel.Grpc code-first and Swashbuckle.AspNetCore integration, add service to the routing pipeline.

var builder = WebApplication.CreateBuilder();

// Swashbuckle.AspNetCore
builder.Services.AddMvc();
builder.Services.AddSwaggerGen(c =>
{
    c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "1.0" });
    c.EnableAnnotations(true, true);
    c.UseAllOfForInheritance();
    c.SchemaGeneratorOptions.SubTypesSelector = SwaggerTools.GetDataContractKnownTypes;
});

// enable ServiceModel.Grpc code-first
builder.Services.AddServiceModelGrpc(options => { ... });

// enable ServiceModel.Grpc integration for Swashbuckle.AspNetCore
builder.Services.AddServiceModelGrpcSwagger();

var app = builder.Build();

// Swashbuckle.AspNetCore
app.UseSwagger();
app.UseSwaggerUI(c =>
{
    c.SwaggerEndpoint("v1/swagger.json", "1.0");
});

// 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();

UI demo

Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.13.0 824 2/2/2025
1.12.0 455 1/12/2025
1.11.1 1,024 11/30/2024
1.11.0 309 11/23/2024
1.10.1 7,696 10/19/2024
1.9.1 982 9/29/2024
1.9.0 4,237 7/21/2024
1.8.3 4,487 5/18/2024
1.8.2 2,853 3/2/2024
1.8.1 3,323 2/13/2024
1.8.0 3,370 1/7/2024
1.7.0 507 12/24/2023
1.6.1 7,112 11/25/2023
1.6.0 6,426 9/9/2023
1.5.2 5,975 6/25/2023
1.5.1 5,783 5/1/2023
1.5.0 4,678 3/7/2023
1.4.13 5,053 12/19/2022
1.4.12 1,169 11/19/2022
1.4.11 944 10/23/2022
1.4.10 645 8/14/2022
1.4.9 511 7/23/2022
1.4.8 461 5/29/2022
1.4.7 436 5/21/2022
1.4.6 500 4/3/2022
1.4.5 476 3/26/2022
1.4.4 551 3/12/2022
1.4.3 512 2/5/2022
1.4.2 622 1/22/2022
1.4.1 305 1/8/2022
1.4.0 2,513 11/26/2021
1.3.2 426 11/5/2021
1.3.1 465 10/10/2021
1.3.0 493 7/31/2021
1.2.1 564 6/12/2021
1.2.0-pre1 292 6/6/2021