/// <summary> /// Adds swagger documents and UI to the request pipeline. /// </summary> /// <param name="app">The application builder.</param> /// <returns>The application builder.</returns> public static IApplicationBuilder UseSwagger(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(); return(app); }
public static void UseSwaggerDocumenting(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", $"{APITitle} {APIVersion}"); }); }
public static IApplicationBuilder UseSwagger(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "v1")); return(app); }
public static void UseSwagger(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "DotNetSurfer V1"); c.RoutePrefix = string.Empty; }); }
public static void UseMySwagger(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { c.SwaggerEndpoint("swagger/v1/swagger.json", "My API V1"); c.RoutePrefix = "swagger"; }); }
public static void UseSwagger(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1"); }); }
/// <summary> /// The function for Swagger configuration /// </summary> /// <param name="app"></param> public static void UseSwagger(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); //To serve the Swagger UI at the app's root (http://localhost:<port>/) c.RoutePrefix = string.Empty; }); }
/// <summary> /// Specify Swagger options /// </summary> /// <param name="app"></param> /// <returns></returns> public static IApplicationBuilder UseSwaggerWithOptions(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { c.RoutePrefix = string.Empty; c.SwaggerEndpoint(EndPoint, ApiName); }); return app; }
public static IApplicationBuilder UseSwagger(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI( o => { o.SwaggerEndpoint("/swagger/v1/swagger.json", "team.blue test API V1"); o.RoutePrefix = string.Empty; }); return(app); }
/// <summary> /// Swagge中间件 /// </summary> /// <param name="app"></param> /// <returns></returns> public static IApplicationBuilder UseSwagger(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { foreach (var item in _provider.ApiVersionDescriptions) { c.SwaggerEndpoint($"/swagger/{item.GroupName}/swagger.json", "MyMicroService API V" + item.ApiVersion); } }); return(app); }
public static IApplicationBuilder UseSwagger(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "TSKRAI API"); c.DocExpansion(DocExpansion.None); }); return(app); }
public static void ContextWithSwagger(this IApplicationBuilder app) { ContextMiddleware(app); SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUi3(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "IVR API v1"); c.RoutePrefix = "swagger/ui"; }); }
public static IApplicationBuilder UseSwagger(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI( c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "iPlantino Api v1"); // c.SwaggerEndpoint("/swagger/v2/swagger.json", "EGL Mobile Api v2"); }); return(app); }
public static void UseSwagger(this IApplicationBuilder app) { var provider = app.ApplicationServices.GetService <IApiVersionDescriptionProvider>(); SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(setupAction => { foreach (var description in provider.ApiVersionDescriptions) { setupAction.SwaggerEndpoint($"{description.GroupName}/swagger.json", "ZipCo API"); } }); }
public static IApplicationBuilder UseSwaggerWithOptions(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { // Uncomment this line if you want to access the Swagger UI as http://localhost:5000 // c.RoutePrefix = string.Empty; c.SwaggerEndpoint(Constants.Swagger.EndPoint, Constants.Swagger.ApiName); }); return(app); }
public static IApplicationBuilder UseCustomSwashbuckleSwagger(this IApplicationBuilder app) { //app.UseSwagger(); SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Ordering API V1"); c.RoutePrefix = string.Empty; }); return(app); }
/// <summary> /// Use swagger UI and endpoint /// </summary> /// <remarks> /// See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#documenting-api /// </remarks> public static IApplicationBuilder UseSwaggerWithOptions(this IApplicationBuilder app) { // Enable middleware to serve generated Swagger as a JSON endpoint. SwaggerBuilderExtensions.UseSwagger(app); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { // Uncomment this line if you want to access the Swagger UI as http://localhost:5000 // c.RoutePrefix = string.Empty; c.SwaggerEndpoint(Constants.Swagger.EndPoint, Constants.Swagger.ApiName); }); return(app); }
public static IApplicationBuilder UseSwagger(this IApplicationBuilder builder) { var options = builder.ApplicationServices.GetService <IConfiguration>() .GetOptions <SwaggerOptions>(nameof(SwaggerOptions)); if (!options.Enabled) { return(builder); } SwaggerBuilderExtensions.UseSwagger(builder); builder.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "v1"); c.RoutePrefix = string.Empty; }); return(builder); }
public static void UseSwagger(this IApplicationBuilder app) { var openIdSettings = IocApi.Instance.Resolve <OpenIdSettings>(); SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { c.SwaggerEndpoint(openIdSettings.HostUrl.UriCombine($"/swagger/{GetVersion()}/swagger.json"), $"Main {GetVersion()}"); c.OAuthClientId(openIdSettings.ClientName); var clientSecret = openIdSettings.ClientSecret; c.OAuthClientSecret(clientSecret); c.OAuthClientSecret(clientSecret); c.OAuthClientSecret(clientSecret); c.OAuthRealm(openIdSettings.ApiResourceName); c.OAuthAppName("SwaggerAuth"); }); }
/// <summary> /// Use swagger to setup endpoint for swagger /// </summary> /// <param name="app"></param> /// <returns></returns> public static IApplicationBuilder UseSwagger(this IApplicationBuilder app) { SwaggerBuilderExtensions.UseSwagger(app); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Beepbot v1"); options.RoutePrefix = "api"; options.DocExpansion(DocExpansion.None); options.DisplayRequestDuration(); }); return(app); }
/// <summary> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app"></param> /// <param name="env"></param> public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "ReverseGeoCode.WebApi v1")); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseAndConfigureSwagger(); }
public void Configure(IApplicationBuilder app, IApiVersionDescriptionProvider apiVersionDescriptionProvider, IWebHostEnvironment env) { app.UseIpRateLimiting(); if (env.EnvironmentName == "Development") { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); SwaggerBuilderExtensions.UseSwagger(app); app.UseCustomSwaggerUI(apiVersionDescriptionProvider, nameof(Api)); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseStaticFiles(); app.UseHttpCacheHeaders(); app.UseCookiePolicy(); app.UseEndpoints(endpoints => endpoints.MapControllers()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseSpaStaticFiles(); SwaggerBuilderExtensions.UseSwagger(app); NSwagApplicationBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "CinemaCporeReactProject V1"); }); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { spa.Options.SourcePath = "clientapp1"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); app.UseAuthentication(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public async void Configure(IApplicationBuilder app, IHostingEnvironment 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(); } SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); //To serve the Swagger UI at the app's root (http://localhost:<port>/) c.RoutePrefix = string.Empty; }); app.UseHttpsRedirection(); app.UseMvc(); await app.UseOcelot(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMiddleware <LogMiddleware>(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Test API V1"); }); loggerFactory.AddSerilog(); loggerFactory.AddFile(pathFormat: "Logs/AspNetCoreWebService-{Date}.txt", outputTemplate: "{Timestamp:o} [RequestId: {RequestId,13}] [{Level:u3}] {Message} ({EventId:x8}){NewLine}{Exception}"); }
public void UseSwagger(IApplicationBuilder app, IApiVersionDescriptionProvider provider) { app.UseSwagger(options => options.SerializeAsV2 = true); SwaggerBuilderExtensions.UseSwagger(app); app.UseSwaggerUI(options => { options.DefaultModelRendering(ModelRendering.Model); options.DefaultModelExpandDepth(1); options.DisplayOperationId(); options.DocExpansion(DocExpansion.None); options.DocumentTitle = "SMS Swagger"; options.InjectStylesheet("/swagger-material.css"); foreach (var description in provider.ApiVersionDescriptions) { options.SwaggerEndpoint( $"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant()); options.RoutePrefix = string.Empty; } }); }
public static IApplicationBuilder UseSwagger( this IApplicationBuilder builder, Action <SwaggerOptions> configureSwaggerOptions = null, Action <SwaggerUIOptions> configureSwaggerUiOptions = null, params ServiceInfo[] serviceInfo ) { SwaggerBuilderExtensions.UseSwagger(builder, configureSwaggerOptions); builder.UseSwaggerUI(options => { foreach (var info in serviceInfo) { options.SwaggerEndpoint ( $"../swagger/{info.Version.ToLower()}/swagger.json", $"{info.Title} {info.Version.ToUpper()}" ); } configureSwaggerUiOptions?.Invoke(options); }); return(builder); }
public static IApplicationBuilder UseSwagger(this IApplicationBuilder app) => SwaggerBuilderExtensions.UseSwagger(app) .UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "API V1"); });