Skip to content

Commit

Permalink
Simplify sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Jun 4, 2024
1 parent 422fb18 commit dbcff55
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
11 changes: 9 additions & 2 deletions src/Grpc/JsonTranscoding/test/testassets/Sandbox/Startup.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,14 +12,19 @@ public class Startup
public void ConfigureServices(IServiceCollection services)
{
services.AddGrpc().AddJsonTranscoding();
services.AddMvc();
//services.AddMvc();

services.AddOpenApi();

#region Secret
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
Expand All @@ -43,7 +50,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseEndpoints(endpoints =>
{
endpoints.MapOpenApi();
endpoints.MapGrpcService<JsonTranscodingGreeterService>();
//endpoints.MapGrpcService<JsonTranscodingGreeterService>();
endpoints.MapGrpcService<GreeterService>();
});
}
Expand Down
7 changes: 7 additions & 0 deletions src/Grpc/JsonTranscoding/test/testassets/Sandbox/greet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
}

0 comments on commit dbcff55

Please sign in to comment.