Skip to content

Instantly share code, notes, and snippets.

@beachside-project
Created September 28, 2022 15:04
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 beachside-project/4f5859be4cc53dcf6ab6829c15182e86 to your computer and use it in GitHub Desktop.
Save beachside-project/4f5859be4cc53dcf6ab6829c15182e86 to your computer and use it in GitHub Desktop.
specify version
using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
// バージョンの指定
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v2", new OpenApiInfo { Title = "My API", Version = "v2" });
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
// エンドポイントの指定
app.UseSwaggerUI(config =>
{
config.SwaggerEndpoint("/swagger/v2/swagger.json", "API v2");
});
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment