3
3
using Microsoft . AspNetCore . Http ;
4
4
using Microsoft . Extensions . DependencyInjection ;
5
5
using Microsoft . Extensions . Hosting ;
6
- using Microsoft . OpenApi . Models ;
7
- using System ;
8
6
using System . IO ;
9
7
10
8
namespace Grpc . HttpApi . Sample
11
9
{
10
+ /// <summary>
11
+ /// startup
12
+ /// </summary>
12
13
public class Startup
13
14
{
14
- // This method gets called by the runtime. Use this method to add services to the container.
15
- // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
15
+
16
+ /// <summary>
17
+ /// This method gets called by the runtime. Use this method to add services to the container.
18
+ /// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
19
+ /// </summary>
20
+ /// <param name="services"></param>
16
21
public void ConfigureServices ( IServiceCollection services )
17
22
{
18
23
services . AddGrpc ( ) ;
19
24
20
25
services . AddGrpcHttpApi ( ) ;
21
26
22
- services . AddSwaggerGen ( c =>
27
+
28
+ services . AddGrpcSwagger ( ( option ) =>
23
29
{
24
-
25
- c . SwaggerDoc ( "v1" , new OpenApiInfo { Title = "gRPC HTTP API Example" , Version = "v1" } ) ;
26
-
27
- var xml = $ "{ typeof ( Startup ) . Assembly . GetName ( ) . Name } .xml";
28
- var path = Path . Combine ( AppContext . BaseDirectory , xml ) ;
29
- if ( File . Exists ( path ) )
30
- {
31
- c . IncludeXmlComments ( path ) ;
32
- }
30
+ option . ApiInfo = new Swagger . SwaggerApiInfo ( ) { Title = "Grpc HttpApi Swagger Sample" } ;
33
31
} ) ;
34
-
35
- services . AddGrpcSwagger ( ) ;
36
32
}
37
33
38
34
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
35
+ /// <summary>
36
+ /// gen
37
+ /// </summary>
38
+ /// <param name="app"></param>
39
+ /// <param name="env"></param>
39
40
public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
40
41
{
41
42
if ( env . IsDevelopment ( ) )
@@ -45,10 +46,9 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
45
46
46
47
app . UseRouting ( ) ;
47
48
48
- app . UseSwagger ( option=> {
49
- option . SerializeAsV2 = true ;
50
- } ) ;
49
+ app . UseSwagger ( ) ;
51
50
51
+ app . UseSwaggerUI ( ) ;
52
52
/*
53
53
app.UseSwaggerUI(c =>
54
54
{
0 commit comments