Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Last active February 7, 2024 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gistlyn/dac47b68e77796902cde0f0b7b9c6ac2 to your computer and use it in GitHub Desktop.
Save gistlyn/dac47b68e77796902cde0f0b7b9c6ac2 to your computer and use it in GitHub Desktop.
openapi3
dotnet add package Microsoft.AspNetCore.OpenApi
dotnet add package Swashbuckle.AspNetCore
dotnet add package ServiceStack.AspNetCore.OpenApi
[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.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