57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using GeradoresService.DAL;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.OpenApi.Models;
|
|
using Primus.ProfitabilityModel.WebAPI.Filters;
|
|
using System.Text.Json.Serialization;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddControllers().AddJsonOptions(options =>
|
|
{
|
|
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
|
});
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen(options =>
|
|
{
|
|
options.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
|
|
options.SwaggerDoc("v1", new OpenApiInfo
|
|
{
|
|
|
|
Version = "v1",
|
|
Title = "FactoryId",
|
|
Contact = new OpenApiContact
|
|
{
|
|
Name = "Marco Santos"
|
|
},
|
|
});
|
|
|
|
// Registra o filtro de esquema que aplica descrições para todos os enums
|
|
options.SchemaFilter<EnumDescriptionFilter>();
|
|
});
|
|
|
|
|
|
var connectionString = builder.Configuration.GetConnectionString("GeradoresConnection");
|
|
builder.Services.AddDbContext<GeradoresContext>(options => options.UseSqlServer(connectionString));
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.UseCors(options =>
|
|
{
|
|
options.AllowAnyOrigin();
|
|
options.AllowAnyMethod();
|
|
options.AllowAnyHeader();
|
|
});
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|