added swagger and appdbcontext to startup file
This commit is contained in:
1 parent
0801058b6d
commit
762e405592
1 file changed
+17
-2
+17
-2
@@ -1,17 +1,32 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using api.Data;
|
||||
using api.Repositories;
|
||||
using api.Services;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
builder.Services.AddOpenApi();
|
||||
// builder.Services.AddOpenApi();
|
||||
|
||||
builder.Services.AddDbContext<AppDbContext>(options => options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
|
||||
|
||||
|
||||
builder.Services.AddScoped<IPersonRepository, PersonRepository>();
|
||||
builder.Services.AddScoped<PersonService, PersonService>();
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
Reference in new issue
Block a user