// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(config => { config.Filters.Add(typeof(ExceptionHandler)); }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1); #region Swagger Generation services.AddSwaggerGen(s => { s.SwaggerDoc("v1", new Info { Title = "Core API", Description = "Core API Swagger Integration" }); }); #endregion #region DB Connection String services.Configure <AppSettingsModel>(Configuration.GetSection("ConnectionStrings")); #endregion #region DAL and BAL Dependncy Injection DALDependnecies.RegisterDALDependnecies(services); BALDependnecies.RegisterBALDependnecies(services); #endregion services.AddAuthentication("BasicAuthentication") .AddScheme <AuthenticationSchemeOptions, BasicAuthenticationHandler>("BasicAuthentication", null); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(options => { options.EnableEndpointRouting = true; options.Filters.Add(typeof(ExceptionHandler)); }).SetCompatibilityVersion(CompatibilityVersion.Latest); #region DB Connection String services.Configure <AppSettingsModel>(Configuration.GetSection("ConnectionStrings")); #endregion #region DAL and BAL Dependncy Injection DALDependnecies.RegisterDALDependnecies(services); BALDependnecies.RegisterBALDependnecies(services); #endregion services.AddApiVersioning( options => { // reporting api versions will return the headers "api-supported-versions" and "api-deprecated-versions" options.ReportApiVersions = true; }); services.AddVersionedApiExplorer( options => { // add the versioned api explorer, which also adds IApiVersionDescriptionProvider service // note: the specified format code will format the version as "'v'major[.minor][-status]" options.GroupNameFormat = "'v'VVV"; // note: this option is only necessary when versioning by url segment. the SubstitutionFormat // can also be used to control the format of the API version in route templates options.SubstituteApiVersionInUrl = true; }); services.AddTransient <IConfigureOptions <SwaggerGenOptions>, ConfigureSwaggerOptions>(); services.AddSwaggerGen( options => { // add a custom operation filter which sets default values options.OperationFilter <SwaggerDefaultValues>(); // integrate xml comments options.IncludeXmlComments(XmlCommentsFilePath); }); }