Skip to content

Commit

Permalink
fix: use bmb.tools package
Browse files Browse the repository at this point in the history
  • Loading branch information
italopessoa committed Nov 22, 2024
1 parent bd51a0a commit aa243a2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations;
using Bmb.Auth;
using Bmb.Tools.Auth;
using FIAP.TechChallenge.ByteMeBurger.Api.Model.Customers;
using FIAP.TechChallenge.ByteMeBurger.Controllers.Contracts;
using FIAP.TechChallenge.ByteMeBurger.Controllers.Dto;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.ObjectModel;
using Bmb.Auth;
using Bmb.Domain.Core.ValueObjects;
using Bmb.Tools.Auth;
using FIAP.TechChallenge.ByteMeBurger.Api.Model.Orders;
using FIAP.TechChallenge.ByteMeBurger.Controllers.Contracts;
using FIAP.TechChallenge.ByteMeBurger.Controllers.Dto;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Bmb.Auth;
using FIAP.TechChallenge.ByteMeBurger.Api.Model.Products;
using FIAP.TechChallenge.ByteMeBurger.Controllers.Contracts;
using FIAP.TechChallenge.ByteMeBurger.Controllers.Dto;
using Bmb.Domain.Core.ValueObjects;
using Bmb.Tools.Auth;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
<AssemblyVersion>1.0.0</AssemblyVersion>
<Product>Bmb Orders/Customer API</Product>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand All @@ -18,8 +20,8 @@
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.MySql" Version="8.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.1" />
<PackageReference Include="Bmb.Auth" Version="0.0.1" />
<PackageReference Include="Bmb.Domain.Core" Version="0.0.17" />
<PackageReference Include="Bmb.Tools" Version="0.0.4" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.3"/>
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
Expand All @@ -28,7 +30,6 @@
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="7.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
</ItemGroup>

<ItemGroup>
Expand Down
44 changes: 4 additions & 40 deletions src/FIAP.TechChallenge.ByteMeBurger.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Text.Json.Serialization;
using Bmb.Auth;
using Bmb.Tools.Auth;
using Bmb.Tools.OpenApi;
using FIAP.TechChallenge.ByteMeBurger.DI;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using Serilog;
using Serilog.Events;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
Expand Down Expand Up @@ -52,37 +50,7 @@ public static void Main(string[] args)
// https://learn.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-8.0#log-automatic-400-responses
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddRouting(options => options.LowercaseUrls = true);
var version = Assembly.GetExecutingAssembly().GetName().Version;
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc($"v{version.Major}", new OpenApiInfo
{
Title = "Tech Challenge Restaurant API", Version = $"v{version.Major}.{version.Minor}.{version.Build}", Extensions =
{
{
"x-logo",
new OpenApiObject
{
{
"url",
new OpenApiString(
"https://avatars.githubusercontent.com/u/165858718?s=384")
},
{
"background",
new OpenApiString(
"#FF0000")
}
}
}
}
});

var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});

builder.Services.ConfigBmbSwaggerGen();
var jwtOptions = builder.Configuration
.GetSection("JwtOptions")
.Get<JwtOptions>();
Expand All @@ -108,11 +76,7 @@ public static void Main(string[] args)
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var version = Assembly.GetExecutingAssembly().GetName().Version.Major;
options.SwaggerEndpoint($"/swagger/v{version}/swagger.yaml", $"v{version}");
});
app.UseBmbSwaggerUi();
}

app.UseSerilogRequestLogging();
Expand Down

0 comments on commit aa243a2

Please sign in to comment.