From 0650d8715cf57f84da0031165208a684d83a70c1 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 5 Jun 2024 07:36:58 +0800 Subject: [PATCH] Simplify sandbox --- .../test/testassets/Sandbox/Sandbox.csproj | 2 ++ .../test/testassets/Sandbox/Startup.cs | 11 +++++++++-- .../test/testassets/Sandbox/greet.proto | 7 +++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Grpc/JsonTranscoding/test/testassets/Sandbox/Sandbox.csproj b/src/Grpc/JsonTranscoding/test/testassets/Sandbox/Sandbox.csproj index 146893e0dd85..2c932c3d364f 100644 --- a/src/Grpc/JsonTranscoding/test/testassets/Sandbox/Sandbox.csproj +++ b/src/Grpc/JsonTranscoding/test/testassets/Sandbox/Sandbox.csproj @@ -1,6 +1,8 @@ $(DefaultNetCoreTargetFramework) + true + $(NoWarn);1591 diff --git a/src/Grpc/JsonTranscoding/test/testassets/Sandbox/Startup.cs b/src/Grpc/JsonTranscoding/test/testassets/Sandbox/Startup.cs index 0bc925f3ca0f..b0e841eecf5a 100644 --- a/src/Grpc/JsonTranscoding/test/testassets/Sandbox/Startup.cs +++ b/src/Grpc/JsonTranscoding/test/testassets/Sandbox/Startup.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Microsoft.Extensions.Options; +using System.Reflection; using Microsoft.OpenApi.Models; namespace Server; @@ -10,7 +12,7 @@ public class Startup public void ConfigureServices(IServiceCollection services) { services.AddGrpc().AddJsonTranscoding(); - services.AddMvc(); + //services.AddMvc(); services.AddOpenApi(); @@ -18,6 +20,11 @@ public void ConfigureServices(IServiceCollection services) services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" }); + + var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; + xmlFilename = Path.Combine(AppContext.BaseDirectory, xmlFilename); + c.IncludeXmlComments(xmlFilename); + c.IncludeGrpcXmlComments(xmlFilename, includeControllerXmlComments: true); }); services.AddGrpcSwagger(); #endregion @@ -43,7 +50,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseEndpoints(endpoints => { endpoints.MapOpenApi(); - endpoints.MapGrpcService(); + //endpoints.MapGrpcService(); endpoints.MapGrpcService(); }); } diff --git a/src/Grpc/JsonTranscoding/test/testassets/Sandbox/greet.proto b/src/Grpc/JsonTranscoding/test/testassets/Sandbox/greet.proto index 4d121a7abcc3..cfb64498bdbf 100644 --- a/src/Grpc/JsonTranscoding/test/testassets/Sandbox/greet.proto +++ b/src/Grpc/JsonTranscoding/test/testassets/Sandbox/greet.proto @@ -7,12 +7,15 @@ import "google/api/annotations.proto"; package greet; +// The greeting service definition. service Greeter { + // Sends a greeting. rpc SayHello (HelloRequest) returns (HelloReply) { option (google.api.http) = { get: "/v1/greeter/{name}" }; } + // Sends a greeting from someone. rpc SayHelloFrom (HelloRequestFrom) returns (HelloReply) { option (google.api.http) = { post: "/v1/greeter" @@ -22,15 +25,19 @@ service Greeter { } message HelloRequest { + // Name to greet. string name = 1; } message HelloRequestFrom { + // Name to greet. string name = 1; + // Greeting from. string from = 2; } message HelloReply { + // Greeting message. string message = 1; HelloReply nested = 2; }