diff --git a/MongoWebApiStarterTemplate.csproj b/MongoWebApiStarterTemplate.csproj index c227670..270578d 100644 --- a/MongoWebApiStarterTemplate.csproj +++ b/MongoWebApiStarterTemplate.csproj @@ -2,12 +2,10 @@ - 7.6.0 + 7.6.1 - - implement separate domain entity mappers - - update vs extension - - upgrade dependancies + - upgrade fastendpoints to v3.0 Template diff --git a/Template/Source/MongoWebApiStarter.csproj b/Template/Source/MongoWebApiStarter.csproj index cce03ee..cfea8ee 100644 --- a/Template/Source/MongoWebApiStarter.csproj +++ b/Template/Source/MongoWebApiStarter.csproj @@ -13,12 +13,12 @@ - - - - - - + + + + + + diff --git a/Template/Source/Program.cs b/Template/Source/Program.cs index e90d1ea..08e2999 100644 --- a/Template/Source/Program.cs +++ b/Template/Source/Program.cs @@ -3,16 +3,13 @@ global using FastEndpoints.Validation; global using MongoDB.Entities; using FastEndpoints.Swagger; -using Microsoft.AspNetCore.Http.Json; using Microsoft.Extensions.Options; using MongoWebApiStarter; using MongoWebApiStarter.Services; -using Swashbuckle.AspNetCore.SwaggerUI; var builder = WebApplication.CreateBuilder(); var configSection = builder.Configuration.GetSection(nameof(Settings)); builder.Services.Configure(configSection); -builder.Services.Configure(o => o.SerializerOptions.PropertyNamingPolicy = null); builder.Services.AddHostedService(); builder.Services.AddHostedService(); @@ -22,32 +19,25 @@ builder.Services.AddResponseCaching(); builder.Services.AddFastEndpoints(); builder.Services.AddAuthenticationJWTBearer(configSection.Get().Auth.SigningKey); -builder.Services.AddSwagger(); +builder.Services.AddSwaggerDoc(); var app = builder.Build(); if (!app.Environment.IsProduction()) { app.UseCors(b => b - .AllowAnyOrigin() - .AllowAnyHeader() - .AllowAnyMethod()); + .AllowAnyOrigin() + .AllowAnyHeader() + .AllowAnyMethod()); + + app.UseOpenApi(); + app.UseSwaggerUi3(c => c.ConfigureDefaults()); } app.UseAuthentication(); app.UseAuthorization(); app.UseResponseCaching(); -app.UseFastEndpoints(); - -if (!app.Environment.IsProduction()) -{ - app.UseSwagger(); - app.UseSwaggerUI(o => - { - o.DocExpansion(DocExpansion.None); - o.DefaultModelExpandDepth(0); - }); -} +app.UseFastEndpoints(c => c.SerializerOptions = o => o.PropertyNamingPolicy = null); var settings = app.Services.GetRequiredService>().Value; await DB.InitAsync(settings.Database.Name, settings.Database.Host); diff --git a/Template/Source/[Features]/Account/Login/Endpoint.cs b/Template/Source/[Features]/Account/Login/Endpoint.cs index 10c3a69..8b134ff 100644 --- a/Template/Source/[Features]/Account/Login/Endpoint.cs +++ b/Template/Source/[Features]/Account/Login/Endpoint.cs @@ -33,7 +33,7 @@ public override async Task HandleAsync(Request r, CancellationToken ct) var expiryDate = DateTime.UtcNow.AddDays(1); - Response.FullName = $"{acc.Title} {acc.FirstName} {acc.LastName}"; + Response.FullName = $"{acc!.Title} {acc.FirstName} {acc.LastName}"; Response.Token.Expiry = expiryDate.ToLocal().ToString("yyyy-MM-ddTHH:mm:ss"); Response.Token.Value = JWTBearer.CreateToken( signingKey: Settings.Value.Auth.SigningKey, diff --git a/Template/Tests/MongoWebApiStarter.Tests.csproj b/Template/Tests/MongoWebApiStarter.Tests.csproj index 7e82686..277a280 100644 --- a/Template/Tests/MongoWebApiStarter.Tests.csproj +++ b/Template/Tests/MongoWebApiStarter.Tests.csproj @@ -8,7 +8,7 @@ - +