Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Last active November 26, 2025 15:03
Show Gist options
  • Select an option

  • Save gistlyn/d0a5db6afd43010ede2e3bac5875f639 to your computer and use it in GitHub Desktop.

Select an option

Save gistlyn/d0a5db6afd43010ede2e3bac5875f639 to your computer and use it in GitHub Desktop.
openapi-swashbuckle
dotnet add package ServiceStack.AspNetCore.OpenApi3
using ServiceStack;
[assembly: HostingStartup(typeof(MyApp.ConfigureOpenApi))]
namespace MyApp;
public class ConfigureOpenApi : IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices((context, services) => {
if (context.HostingEnvironment.IsDevelopment())
{
services.AddEndpointsApiExplorer();
services.AddSwaggerGen();
services.AddServiceStackSwagger();
// services.AddBasicAuth<Data.ApplicationUser>();
// services.AddApiKeys();
// services.AddJwtAuth();
services.AddTransient<IStartupFilter,StartupFilter>();
}
});
public class StartupFilter : IStartupFilter
{
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next) => app =>
{
app.UseSwagger();
app.UseSwaggerUI();
next(app);
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment