-
Notifications
You must be signed in to change notification settings - Fork 24.6k
Delete aspnetcore/grpc/json-transcoding-openapi.md #37440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4246931
Delete aspnetcore/grpc/json-transcoding-openapi.md
Youssef1313 7a21af4
Delete aspnetcore/grpc/json-transcoding-openapi directory
Youssef1313 7b8599b
Update json-transcoding.md
Youssef1313 b0b221d
Update aspnetcore-7.0.md
Youssef1313 bdf0f88
Update toc.yml
Youssef1313 112023f
Update json-transcoding7.md
Youssef1313 349dd1a
Restore gRPC OpenAPI deprecation article
Copilot b2a5a62
Apply suggestions from code review
wadepickett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,73 +1,17 @@ | ||
| --- | ||
| title: Use OpenAPI with gRPC JSON transcoding ASP.NET Core apps | ||
| title: gRPC JSON transcoding and OpenAPI | ||
| ai-usage: ai-assisted | ||
| author: jamesnk | ||
| description: Learn how to configure gRPC JSON transcoding to generate OpenAPI. | ||
| description: The `Microsoft.AspNetCore.Grpc.Swagger` package has been deprecated. | ||
| monikerRange: '>= aspnetcore-7.0' | ||
| ms.author: wpickett | ||
| ms.date: 02/19/2025 | ||
| ms.date: 08/16/2026 | ||
| uid: grpc/json-transcoding-openapi | ||
| --- | ||
| # gRPC JSON transcoding documentation with Swagger / OpenAPI | ||
|
|
||
| [!INCLUDE[](~/includes/not-latest-version.md)] | ||
| # gRPC JSON transcoding and OpenAPI | ||
|
|
||
| By [James Newton-King](https://twitter.com/jamesnk) | ||
|
|
||
| [OpenAPI (Swagger)](https://swagger.io/specification/) is a language-agnostic specification for describing REST APIs. gRPC JSON transcoding supports generating OpenAPI from transcoded RESTful APIs. The [`Microsoft.AspNetCore.Grpc.Swagger`](https://www.nuget.org/packages/Microsoft.AspNetCore.Grpc.Swagger) package: | ||
|
|
||
| * Integrates gRPC JSON transcoding with [Swashbuckle](xref:tutorials/get-started-with-swashbuckle). | ||
| * Is experimental in .NET 7 to allow us to explore the best way to provide OpenAPI support. | ||
|
|
||
| ## Get started | ||
|
|
||
| To enable OpenAPI with gRPC JSON transcoding: | ||
|
|
||
| 1. Setup gRPC JSON transcoding by following the [getting started instructions](xref:grpc/json-transcoding#usage). | ||
| 2. Add a package reference to [`Microsoft.AspNetCore.Grpc.Swagger`](https://www.nuget.org/packages/Microsoft.AspNetCore.Grpc.Swagger). The version must be 0.3.0-xxx or later. | ||
| 3. Configure Swashbuckle in startup. The `AddGrpcSwagger` method configures Swashbuckle to include gRPC endpoints. | ||
|
|
||
| [!code-csharp[](~/grpc/json-transcoding-openapi/Program.cs?name=snippet_1&highlight=3-8,11-16)] | ||
|
|
||
| [!INCLUDE[](~/includes/package-reference.md)] | ||
|
|
||
| ## Add OpenAPI descriptions from `.proto` comments | ||
|
|
||
| Generate OpenAPI descriptions from comments in the `.proto` contract, as in the following example: | ||
|
|
||
| ```protobuf | ||
| // My amazing greeter service. | ||
| service Greeter { | ||
| // Sends a greeting. | ||
| rpc SayHello (HelloRequest) returns (HelloReply) { | ||
| option (google.api.http) = { | ||
| get: "/v1/greeter/{name}" | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| message HelloRequest { | ||
| // Name to say hello to. | ||
| string name = 1; | ||
| } | ||
| message HelloReply { | ||
| // Hello reply message. | ||
| string message = 1; | ||
| } | ||
| ``` | ||
|
|
||
| To enable gRPC OpenAPI comments: | ||
|
|
||
| 1. Enable the XML documentation file in the server project with `<GenerateDocumentationFile>true</GenerateDocumentationFile>`. | ||
| 2. Configure `AddSwaggerGen` to read the generated XML file. Pass the XML file path to `IncludeXmlComments` and `IncludeGrpcXmlComments`, as in the following example: | ||
|
|
||
| [!code-csharp[](~/grpc/json-transcoding-openapi/Program2.cs?name=snippet_1&highlight=6-8)] | ||
|
|
||
| To confirm that Swashbuckle is generating OpenAPI with descriptions for the RESTful gRPC services, start the app and navigate to the Swagger UI page: | ||
|
|
||
|  | ||
|
|
||
| ## Additional resources | ||
|
|
||
| * <xref:grpc/json-transcoding> | ||
| * [OpenAPI homepage](https://www.openapis.org/) | ||
| * [`Swashbuckle.AspNetCore` GitHub repository](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) | ||
| > [!IMPORTANT] | ||
| > The `Microsoft.AspNetCore.Grpc.Swagger` package described by this article was | ||
| > experimental and has been deprecated. It has no direct replacement. For more | ||
| > information, see [Deprecate Microsoft.AspNetCore.Grpc.Swagger (dotnet/aspnetcore #67134)](https://github.com/dotnet/aspnetcore/issues/67134). | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.