public ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider) => this.provider = provider;
Пример #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// <summary>  </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        /// <param name="serviceProvider"></param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider, IApiVersionDescriptionProvider provider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseServices(Configuration, Environment, Logger);

            app.UseSwagger(c =>
            {
                c.RouteTemplate = "api/{documentName}/transactionqueue/swagger/swagger.json";
            });
            app
            .UseSwaggerUI(c =>
            {
                //Build a swagger endpoint for each discovered API version
                foreach (var description in provider.ApiVersionDescriptions)
                {
                    c.SwaggerEndpoint($"/api/{description.GroupName}/transactionqueue/swagger/swagger.json", "TransactionQueue API " + description.GroupName.ToUpperInvariant());
                }
                c.RoutePrefix = "api/v1/transactionqueue/swagger";
            });

            var webSocketOptions = new WebSocketOptions()
            {
                KeepAliveInterval = TimeSpan.FromSeconds(120),
                ReceiveBufferSize = 4 * 1024,
            };

            app.UseWebSockets(webSocketOptions);
            app.MapWebSocketManager("/notifications", serviceProvider.GetService <TQMessageHandler>());
        }
Пример #3
0
 /// <summary>
 /// Configures the application using the provided builder, hosting environment, and logging factory.
 /// </summary>
 /// <param name="app">The current application builder.</param>
 /// <param name="env">The current hosting environment.</param>
 /// <param name="modelBuilder">The <see cref="VersionedODataModelBuilder">model builder</see> used to create OData entity data models (EDMs).</param>
 /// <param name="provider">The API version descriptor provider used to enumerate defined API versions.</param>
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, VersionedODataModelBuilder modelBuilder, IApiVersionDescriptionProvider provider)
 {
     app.UseMvc(routeBuilder => routeBuilder.MapVersionedODataRoutes("odata", "api", modelBuilder.GetEdmModels()));
     app.UseSwagger();
     app.UseSwaggerUI(
         options =>
     {
         // build a swagger endpoint for each discovered API version
         foreach (var description in provider.ApiVersionDescriptions)
         {
             options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant());
         }
     });
 }
Пример #4
0
        public static IApplicationBuilder UseSwaggerConfig(this IApplicationBuilder app, IApiVersionDescriptionProvider provider)
        {
            //app.UseMiddleware<SwaggerAuthorizedMiddleware>();
            app.UseSwagger();
            app.UseSwaggerUI(
                options =>
            {
                foreach (var description in provider.ApiVersionDescriptions)
                {
                    options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant());
                }
            });

            return(app);
        }
Пример #5
0
        public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env, VersionedODataModelBuilder modelBuilder, IApiVersionDescriptionProvider provider)
        {
            if (env.IsDevelopment())
            {
                _ = app.UseDeveloperExceptionPage();
            }
            else
            {
                _ = app.UseHsts();
            }

            _ = app.UseAuthentication()
                .UseAuthorization();
            _ = app
                .UseMvc(routeBuilder =>
            {
                var models    = modelBuilder.GetEdmModels().ToList();
                var singleton = Microsoft.OData.ServiceLifetime.Singleton;
                _             = routeBuilder
                                .SetTimeZoneInfo(TimeZoneInfo.Utc)
                                .Select()
                                .Expand()
                                .OrderBy()
                                .MaxTop(MaxTop ?? 100)
                                .Filter()
                                .Count()
                                .MapVersionedODataRoutes("odata-bypath", "odata/v{version:apiVersion}", models, oBuilder =>
                {
                    _ = oBuilder.AddService <ODataSerializerProvider, NrsrxODataSerializerProvider>(singleton);
                });
            })
                .UseSwagger()
                .UseSwaggerUI(options => SetupSwaggerUI(options, provider));
        }
 public static void ConfigureSwaggerVersions(this SwaggerGenOptions swaggerOptions, IApiVersionDescriptionProvider provider)
 {
     swaggerOptions.ConfigureSwaggerVersions(provider, "API Version {0}");
 }
 public ConfigureSwaggerApiVersioning(IApiVersionDescriptionProvider provider)
 {
     _provider = provider;
 }
Пример #8
0
 public ConfigureSwaggerUIOptions(IApiVersionDescriptionProvider versionProvider)
 => _versionProvider = versionProvider;
Пример #9
0
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider)
 {
     app.UseMvcConfiguration(env);
     app.UseSwaggerConfig(provider);
     app.UseHealthCheckConfiguration();
 }
Пример #10
0
        public static IApplicationBuilder UseSwaggerDocs(this IApplicationBuilder app, IApiVersionDescriptionProvider provider)
        {
            app.UseSwagger();
            app.UseSwaggerUI(
                options =>
            {
                // build a swagger endpoint for each discovered API version
                foreach (var description in provider.ApiVersionDescriptions)
                {
                    options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant());
                }
            });

            return(app);
        }
Пример #11
0
        public void Configure(
            IServiceProvider serviceProvider,
            IApplicationBuilder app,
            IWebHostEnvironment env,
            IHostApplicationLifetime appLifetime,
            ILoggerFactory loggerFactory,
            IApiVersionDescriptionProvider apiVersionProvider,
            ApiDataDogToggle datadogToggle,
            ApiDebugDataDogToggle debugDataDogToggle,
            HealthCheckService healthCheckService)
        {
            StartupHelpers.CheckDatabases(healthCheckService, DatabaseTag).GetAwaiter().GetResult();

            app
            .UseDataDog <Startup>(new DataDogOptions
            {
                Common =
                {
                    ServiceProvider = serviceProvider,
                    LoggerFactory   = loggerFactory
                },
                Toggles =
                {
                    Enable = datadogToggle,
                    Debug  = debugDataDogToggle
                },
                Tracing =
                {
                    ServiceName = _configuration["DataDog:ServiceName"],
                }
            })

            .UseDefaultForApi(new StartupUseOptions
            {
                Common =
                {
                    ApplicationContainer = _applicationContainer,
                    ServiceProvider      = serviceProvider,
                    HostingEnvironment   = env,
                    ApplicationLifetime  = appLifetime,
                    LoggerFactory        = loggerFactory,
                },
                Api =
                {
                    VersionProvider     = apiVersionProvider,
                    Info                = groupName => $"Basisregisters.Vlaanderen - Postal Information Registry API {groupName}",
                    CSharpClientOptions =
                    {
                        ClassName = "PostalRegistryExtract",
                        Namespace = "Be.Vlaanderen.Basisregisters"
                    },
                    TypeScriptClientOptions =
                    {
                        ClassName           = "PostalRegistryExtract"
                    }
                },
                Server =
                {
                    PoweredByName = "Vlaamse overheid - Basisregisters Vlaanderen",
                    ServerName    = "Digitaal Vlaanderen"
                },
                MiddlewareHooks =
                {
                    AfterMiddleware = x => x.UseMiddleware <AddNoCacheHeadersMiddleware>()
                }
            });
        }
Пример #12
0
        /// <summary>
        /// Configures the specified application.
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="app">The application.</param>
        /// <param name="env">The env.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="provider">The provider.</param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApiVersionDescriptionProvider provider)
        {
            app           = app ?? throw new ArgumentNullException(nameof(app));
            env           = env ?? throw new ArgumentNullException(nameof(env));
            loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
            provider      = provider ?? throw new ArgumentNullException(nameof(provider));

            app.UseAuthentication();
            app.UsePSESwagger(provider, ServiceConfiguration.AppName);
            app.UseMvc();
        }
Пример #13
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime appLifetime, IApiVersionDescriptionProvider provider)
        {
            try
            {
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                }

                app.UseLykkeMiddleware(ex => new { Message = "Technical problem" });

                app.UseCors(builder =>
                {
                    builder.AllowAnyOrigin();
                    builder.AllowAnyHeader();
                    builder.AllowAnyMethod();
                });

                app.UseAuthentication();

                app.UseMvc();

                app.UseSwagger(c =>
                {
                    c.PreSerializeFilters.Add((swagger, httpReq) =>
                    {
                        swagger.Host    = httpReq.Host.Value;
                        swagger.Schemes = new List <string> {
                            "https", "http"
                        };
                    });
                });

                app.UseSwaggerUI(
                    options =>
                {
                    foreach (var description in provider.ApiVersionDescriptions)
                    {
                        options.RoutePrefix = "swagger/ui";
                        options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
                                                description.GroupName.ToUpperInvariant());
                    }
                });

                app.UseStaticFiles();

                appLifetime.ApplicationStarted.Register(() => StartApplication().GetAwaiter().GetResult());
                appLifetime.ApplicationStopping.Register(() => StopApplication().GetAwaiter().GetResult());
                appLifetime.ApplicationStopped.Register(() => CleanUp().GetAwaiter().GetResult());
            }
            catch (Exception ex)
            {
                _log?.Critical(ex);
                throw;
            }
        }
Пример #14
0
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider)
 {
     ApiConfiguration.UseConfiguration(app, env);
     SwaggerConfiguration.UseConfiguration(app, provider);
 }
Пример #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="provider"></param>
 /// <param name="configuration"></param>
 public ClientSwaggerOptions(IApiVersionDescriptionProvider provider, IConfiguration configuration)
 {
     _configuration = configuration;
     _provider      = provider;
 }
Пример #16
0
        public void Configure(
            IServiceProvider serviceProvider,
            IApplicationBuilder app,
            IWebHostEnvironment env,
            IHostApplicationLifetime appLifetime,
            ILoggerFactory loggerFactory,
            IApiVersionDescriptionProvider apiVersionProvider,
            MsSqlStreamStore streamStore,
            ApiDataDogToggle datadogToggle,
            ApiDebugDataDogToggle debugDataDogToggle,
            HealthCheckService healthCheckService)
        {
            StartupHelpers.EnsureSqlStreamStoreSchema <Startup>(streamStore, loggerFactory);

            app
            .UseDataDog <Startup>(new DataDogOptions
            {
                Common =
                {
                    ServiceProvider = serviceProvider,
                    LoggerFactory   = loggerFactory
                },
                Toggles =
                {
                    Enable = datadogToggle,
                    Debug  = debugDataDogToggle
                },
                Tracing =
                {
                    ServiceName = _configuration["DataDog:ServiceName"],
                }
            })

            .UseDefaultForApi(new StartupUseOptions
            {
                Common =
                {
                    ApplicationContainer = _applicationContainer,
                    ServiceProvider      = serviceProvider,
                    HostingEnvironment   = env,
                    ApplicationLifetime  = appLifetime,
                    LoggerFactory        = loggerFactory,
                },
                Api =
                {
                    VersionProvider     = apiVersionProvider,
                    Info                = groupName => $"Basisregisters Vlaanderen - Municipality Registry API {groupName}",
                    CSharpClientOptions =
                    {
                        ClassName = "MunicipalityRegistryCrabImport",
                        Namespace = "Be.Vlaanderen.Basisregisters"
                    },
                    TypeScriptClientOptions =
                    {
                        ClassName           = "MunicipalityRegistryCrabImport"
                    }
                },
                MiddlewareHooks =
                {
                    AfterMiddleware = x => x.UseMiddleware <AddNoCacheHeadersMiddleware>(),
                }
            })

            .UseIdempotencyDatabaseMigrations()
            .UseCrabImportMigrations();

            StartupHelpers.CheckDatabases(healthCheckService, DatabaseTag).GetAwaiter().GetResult();
        }
Пример #17
0
        public void BaseConfigure(IApplicationBuilder app, ILoggerFactory loggerFactory, IApiVersionDescriptionProvider provider)
        {
            //app.UseCors("CorsPolicy");

            //app.UseSwagger();

            //app.UseSwaggerUI(
            // options =>
            // {
            //     foreach (var description in provider.ApiVersionDescriptions)
            //     {
            //         options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant());
            //     }
            // });
        }
Пример #18
0
 public SwaggerGenConfiguration(IApiVersionDescriptionProvider provider)
 {
     this._provider = provider;
 }
        public static void ConfigureSwaggerVersions(this SwaggerGenOptions swaggerOptions, IApiVersionDescriptionProvider provider, string titleTemplate)
        {
            foreach (var description in provider.ApiVersionDescriptions)
            {
                var title = string.Format(titleTemplate, description.ApiVersion);
                swaggerOptions.SwaggerDoc(description.GroupName, new Info {
                    Version = description.ApiVersion.ToString(), Title = title
                });
            }

            swaggerOptions.OperationFilter <CorrectOperationIdsOperationFilter>();
            swaggerOptions.OperationFilter <RemoveVersionParametersOperationFilter>();
            swaggerOptions.DocumentFilter <SetVersionInPathsDocumentFilter>();
        }
Пример #20
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, IApiVersionDescriptionProvider provider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseSession();
            app.UseAuthentication();
            app.UseRouting();
            app.UseAuthorization();
            app.UseEndpoints(options => options.MapControllerRoute(
                                 name: "default",
                                 pattern: "{controller=Home}/{action=Index}/{id?}"));
            app.UseSwagger();
            app.UseSwaggerUI(options =>
            {
                foreach (var description in provider.ApiVersionDescriptions)
                {
                    options.SwaggerEndpoint(
                        $"/swagger/{description.GroupName}/swagger.json",
                        description.GroupName.ToUpperInvariant());
                }
            });

            using var scope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope();
            scope.ServiceProvider.GetRequiredService <ISqliteDataContext>().Migrate();
        }