Created
September 28, 2022 15:04
-
-
Save beachside-project/4f5859be4cc53dcf6ab6829c15182e86 to your computer and use it in GitHub Desktop.
specify version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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