Exemplo n.º 1
0
        public async Task BeforeAll()
        {
            _host = await new KestrelHost()
                    .ConfigureServices(services =>
            {
                services.AddGrpc(options =>
                {
                    options.ResponseCompressionAlgorithm = options.CompressionProviders[0].EncodingName;
                    options.ResponseCompressionLevel     = CompressionLevel.Optimal;
                });
                services.AddServiceModelGrpcSwagger();
                services.AddSwaggerGen(c =>
                {
                    c.SwaggerDoc("v1", new OpenApiInfo {
                        Title = "My API", Version = "v1"
                    });
                    c.EnableAnnotations(true, true);
                });
                services.AddMvc();
            })
                    .ConfigureApp(app =>
            {
                app.UseSwagger();
                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("v1/swagger.json", "My API V1");
                });

                app.UseServiceModelGrpcSwaggerGateway();
            })
                    .ConfigureEndpoints(endpoints =>
            {
                endpoints.MapGrpcService <MultipurposeService>();
            })
                    .StartAsync(HttpProtocols.Http1)
                    .ConfigureAwait(false);

            var document = await OpenApiDocument
                           .DownloadAsync(_host.GetLocation("swagger/v1/swagger.json"))
                           .ConfigureAwait(false);

            _client = new SwaggerUiClient(document, nameof(IMultipurposeService), _host.GetLocation());
        }
Exemplo n.º 2
0
        public async Task BeforeAll()
        {
            _host = await new KestrelHost()
                    .ConfigureServices(services =>
            {
                services.AddServiceModelGrpcSwagger();
                services.AddSwaggerGen(c =>
                {
                    c.SwaggerDoc("v1", new OpenApiInfo {
                        Title = "My API", Version = "v1"
                    });
                    c.EnableAnnotations(true, true);
                });
                services.AddMvc();
            })
                    .ConfigureApp(app =>
            {
                app.UseSwagger();
                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("v1/swagger.json", "My API V1");
                });

                app.UseServiceModelGrpcSwaggerGateway();
            })
                    .ConfigureEndpoints(endpoints =>
            {
                endpoints.MapGrpcService <HeadersService>();
            })
                    .StartAsync(HttpProtocols.Http1)
                    .ConfigureAwait(false);

            var document = await OpenApiDocument
                           .DownloadAsync(_host.GetLocation("swagger/v1/swagger.json"))
                           .ConfigureAwait(false);

            _client = new SwaggerUiClient(document, nameof(IHeadersService), _host.GetLocation());
        }