-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Description:
I am using .NET 9 Preview's built-in support for OpenAPI document generation with gRPC JSON transcoding. However, the OpenAPI document generated contains an empty paths
object when the transcoding is enabled. The document generates correctly (without empty paths) when I don't use the transcoding service.
I've followed the tutorial for gRPC JSON transcoding from .NET 8 (available here) and refactored it to incorporate .NET 9 Preview's built-in OpenAPI support (as described here).
However, the paths
in the OpenAPI document remain empty.
Generated OpenAPI Document:
{
"openapi": "3.0.1",
"info": {
"title": "Transcoding | v1",
"version": "1.0.0"
},
"servers": [
{
"url": "http://localhost:5204"
}
],
"paths": {},
"components": {}
}
Program Code:
using Transcoding.Services;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGrpc().AddJsonTranscoding();
builder.Services.AddOpenApi();
var app = builder.Build();
app.MapOpenApi();
app.MapGrpcService<GreeterService>();
app.Run();
Expected Behavior
I expect the OpenAPI document to populate the paths
with the routes corresponding to the gRPC methods exposed via JSON transcoding, similar to how it works without the transcoding services.
Actual Behavior
When using gRPC JSON transcoding with Microsoft.AspNetCore.Grpc.JsonTranscoding
, the generated OpenAPI document has empty paths
. The issue only occurs when transcoding is enabled.
Steps To Reproduce
- Use the preview versions of
Microsoft.AspNetCore.OpenApi
andMicrosoft.AspNetCore.Grpc.JsonTranscoding
. - Follow the instructions from the linked articles to enable gRPC JSON transcoding and OpenAPI document generation.
- Generate the OpenAPI document.
Exceptions (if any)
It does not throw any Exceptions. It just doesn't work as intended.
.NET Version
9.0.100-preview.7.24407.12
Anything else?
ASP.NET core 2.66.0
For reproducibility, I have created a repository that contains the setup where this issue occurs. You can find it here: https://github.com/python3js/Transcoding.