-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
45 lines (35 loc) · 1.36 KB
/
Program.cs
File metadata and controls
45 lines (35 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using PlatformServices.Data;
using AutoMapper;
using PlatformServices.Profiles;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseInMemoryDatabase("InMem"));
builder.Services.AddScoped<IPlatformRepo, PlatformRepo>();
builder.Services.AddSwaggerGen(c=> c.SwaggerDoc("v1", new OpenApiInfo { Title = "PlatformServices", Version = "v1" }));
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
var app = builder.Build();
// Keep MapOpenApi for development-specific behavior if desired
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
// Serve Swagger JSON and the Swagger UI.
// Set RoutePrefix = string.Empty so the UI is available at the app root ("/").
// That makes the browser land on the Swagger UI when the app root is opened.
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "PlatformServices v1");
c.RoutePrefix = string.Empty; // serve Swagger UI at "/"
});
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
PrepDb.PrepPopulation(app);
app.Run();