public ConfigureSwaggerUIOptions(IOptions <SwaggerSetting> settings, IApiVersionDescriptionProvider service) { Debug.Assert(settings != null, $"{nameof(service)} != null"); Debug.Assert(service != null, $"{nameof(service)} != null"); this._settings = settings?.Value ?? new SwaggerSetting(); this._provider = service ?? throw new ArgumentNullException(nameof(service)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { app.UseDeveloperExceptionPage(); app.UseAuthentication(); SwaggerSetting.ConfigureApp(app, env); app.UseMvc(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); SwaggerSetting.ConfigureIdentitySevrer(services); OptionsSetting.ConfigureService(services, Configuration); EntityFrameworkSetting.ConfigureService(services, Configuration); IocSetting.ConfigureService(services, Configuration); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebAssemblyDebugging(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseBlazorFrameworkFiles(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); var swaggerOptions = new SwaggerSetting(); Configuration.GetSection(nameof(SwaggerSetting)).Bind(swaggerOptions); app.UseSwagger(option => { option.RouteTemplate = swaggerOptions.JsonRoute; }); app.UseSwaggerUI(option => { option.SwaggerEndpoint(swaggerOptions.UiEndpoint, swaggerOptions.Description); }); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); endpoints.MapHub <ChatRoomHub>("/chatroomHub"); endpoints.MapFallbackToFile("index.html"); }); }
private void AddSwaggerDocumentForEachDiscoveredApiVersion(SwaggerGenOptions options) { foreach (var description in _provider.ApiVersionDescriptions) { var _settings = new SwaggerSetting(); _settings.Info.Version = description.ApiVersion.ToString(); if (description.IsDeprecated) { _settings.Info.Description += " - DEPRECATED VERSION"; } else { _settings.Info.Description += " - SUPPORTED VERSION"; } options.SwaggerDoc(description.GroupName, _settings.Info); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); var swaggerOptions = new SwaggerSetting(); Configuration.GetSection(nameof(SwaggerSetting)).Bind(swaggerOptions); app.UseSwagger(option => { option.RouteTemplate = swaggerOptions.JsonRoute; }); app.UseSwaggerUI(option => { option.SwaggerEndpoint(swaggerOptions.UiEndpoint, swaggerOptions.Description); }); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); }
public Startup(IConfiguration configuration) { _config = configuration; _swaggerSetting = new SwaggerSetting { Name = "Shopia", Title = "Shopia.Api", Version = "v1.0", Description = $"Copyright © {DateTime.Now.Year} Hillavas Company. All rights reserved.", TermsOfService = "https://cdn-hub.ir/", JsonUrl = "/swagger/v1/swagger.json", Contact = new SwaggerContact { Name = "Mehran Norouzi", Email = "*****@*****.**", Url = "https://hillavas.com/" }, License = new SwaggerLicense { Name = "Hillavas Service Licence", Url = "https://hillavas.com/applicense" } }; }
public ConfigureSwaggerOptions(IOptions <SwaggerSetting> settings) { _settings = settings?.Value ?? new SwaggerSetting(); }