diff --git a/FastEndpoints.TemplatePack.csproj b/FastEndpoints.TemplatePack.csproj
index dd9ebee..0ad7bbe 100644
--- a/FastEndpoints.TemplatePack.csproj
+++ b/FastEndpoints.TemplatePack.csproj
@@ -2,7 +2,7 @@
- 1.5.1
+ 1.6.0
Template
FastEndpoints.TemplatePack
diff --git a/changelog.md b/changelog.md
index 3b0e01d..03d0fe5 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1 +1,3 @@
+- add source generator to projects
+- use `ProblemDetails` for error responses
- upgrade dependencies to latest
\ No newline at end of file
diff --git a/templates/integrated/Source/Entities/Member.cs b/templates/integrated/Source/Entities/Member.cs
index 06f9121..3084276 100644
--- a/templates/integrated/Source/Entities/Member.cs
+++ b/templates/integrated/Source/Entities/Member.cs
@@ -5,12 +5,12 @@ sealed class Member : Entity
public ulong MemberNumber { get; set; }
public DateOnly SignupDate { get; set; }
- public string FirstName { get; set; }
- public string LastName { get; set; }
+ public string FirstName { get; init; }
+ public string LastName { get; init; }
public string Designation { get; set; }
- public string Email { get; set; }
+ public string Email { get; init; }
public DateOnly BirthDay { get; set; }
public string Gender { get; set; }
- public string MobileNumber { get; set; }
+ public string MobileNumber { get; init; }
public Address Address { get; set; }
}
\ No newline at end of file
diff --git a/templates/integrated/Source/Entities/NotificationTemplate.cs b/templates/integrated/Source/Entities/NotificationTemplate.cs
index 8266bee..c292f89 100644
--- a/templates/integrated/Source/Entities/NotificationTemplate.cs
+++ b/templates/integrated/Source/Entities/NotificationTemplate.cs
@@ -5,11 +5,11 @@ namespace Dom;
sealed class NotificationTemplate : IEntity
{
[BsonId]
- public string ID { get; set; } //set the template name as id
+ public string ID { get; init; } //set the template name as id
- public string SmsBody { get; set; }
- public string EmailSubject { get; set; }
- public string EmailBody { get; set; }
+ public string SmsBody { get; init; }
+ public string EmailSubject { get; init; }
+ public string EmailBody { get; init; }
public object GenerateNewID()
=> ID; //because we're setting the ID manually
diff --git a/templates/integrated/Source/Features/Members/SignUp/Request.cs b/templates/integrated/Source/Features/Members/SignUp/Request.cs
index f8433fe..8df59af 100644
--- a/templates/integrated/Source/Features/Members/SignUp/Request.cs
+++ b/templates/integrated/Source/Features/Members/SignUp/Request.cs
@@ -7,22 +7,22 @@ sealed class Request
{
//request dto shape is dictated by front-end team
- public User UserDetails { get; set; }
- public string Email { get; set; }
- public string BirthDay { get; set; }
- public string Gender { get; set; }
- public ContactDetails Contact { get; set; }
- public AddressDetails Address { get; set; }
+ public User UserDetails { get; init; }
+ public string Email { get; init; }
+ public string BirthDay { get; init; }
+ public string Gender { get; init; }
+ public ContactDetails Contact { get; init; }
+ public AddressDetails Address { get; init; }
public sealed class User
{
- public string FirstName { get; set; }
- public string LastName { get; set; }
+ public string FirstName { get; init; }
+ public string LastName { get; init; }
}
public sealed class ContactDetails
{
- public string MobileNumber { get; set; }
+ public string MobileNumber { get; init; }
public bool Whatsapp { get; set; }
public bool Viber { get; set; }
public bool Telegram { get; set; }
@@ -30,13 +30,13 @@ public sealed class ContactDetails
public sealed class AddressDetails
{
- public string Street { get; set; }
- public string City { get; set; }
- public string State { get; set; }
- public string ZipCode { get; set; }
+ public string Street { get; init; }
+ public string City { get; init; }
+ public string State { get; init; }
+ public string ZipCode { get; init; }
}
- sealed class Validator : Validator
+ internal sealed class Validator : Validator
{
public Validator()
{
diff --git a/templates/integrated/Source/MyProject.csproj b/templates/integrated/Source/MyProject.csproj
index a78020b..50f069a 100644
--- a/templates/integrated/Source/MyProject.csproj
+++ b/templates/integrated/Source/MyProject.csproj
@@ -10,13 +10,14 @@
-
+
-
-
-
+
+
+
+
-
+
@@ -24,13 +25,13 @@
false
-
-
+
+
-
-
-
-
+
+
+
+
diff --git a/templates/integrated/Source/Notifications/Commands/SendEmailMessage.cs b/templates/integrated/Source/Notifications/Commands/SendEmailMessage.cs
index 9123a80..fd91e2a 100644
--- a/templates/integrated/Source/Notifications/Commands/SendEmailMessage.cs
+++ b/templates/integrated/Source/Notifications/Commands/SendEmailMessage.cs
@@ -4,10 +4,10 @@ namespace MyProject.Notifications;
public sealed class SendEmailMessage : ICommand
{
- public string ToName { get; set; }
- public string ToEmail { get; set; }
- public string Subject { get; set; }
- public string Body { get; set; }
+ public string ToName { get; init; }
+ public string ToEmail { get; init; }
+ public string Subject { get; init; }
+ public string Body { get; init; }
}
sealed class SendEmailMessageHandler(IAmazonSimpleEmailServiceV2 sesClient, IWebHostEnvironment env, IConfiguration cfg) : ICommandHandler
diff --git a/templates/integrated/Source/Program.cs b/templates/integrated/Source/Program.cs
index b1c95b8..7b15036 100644
--- a/templates/integrated/Source/Program.cs
+++ b/templates/integrated/Source/Program.cs
@@ -1,14 +1,14 @@
using Amazon;
using Amazon.SimpleEmailV2;
-using MyProject;
using Dom;
using FastEndpoints.Security;
+using MyProject;
var bld = WebApplication.CreateBuilder(args);
bld.Services
.AddAuthenticationJwtBearer(o => o.SigningKey = bld.Configuration["Auth:SigningKey"])
.AddAuthorization()
- .AddFastEndpoints()
+ .AddFastEndpoints(o => o.SourceGeneratorDiscoveredTypes.AddRange(DiscoveredTypes.All))
.AddJobQueues()
.AddSingleton(
new AmazonSimpleEmailServiceV2Client(
diff --git a/templates/item/Data.cs b/templates/item/Data.cs
index 2c40659..44b6b65 100644
--- a/templates/item/Data.cs
+++ b/templates/item/Data.cs
@@ -1,6 +1,6 @@
namespace FeatureName;
-static class Data
+sealed class Data
{
}
diff --git a/templates/project/Source/Features/SayHello/Request.cs b/templates/project/Source/Features/SayHello/Request.cs
index f28b0a1..adc3a8c 100644
--- a/templates/project/Source/Features/SayHello/Request.cs
+++ b/templates/project/Source/Features/SayHello/Request.cs
@@ -4,8 +4,8 @@ namespace SayHello;
sealed class Request
{
- public string FirstName { get; set; }
- public string LastName { get; set; }
+ public string FirstName { get; init; }
+ public string LastName { get; init; }
internal sealed class Validator : Validator
{
diff --git a/templates/project/Source/MyProject.csproj b/templates/project/Source/MyProject.csproj
index 1ce3369..d57f678 100644
--- a/templates/project/Source/MyProject.csproj
+++ b/templates/project/Source/MyProject.csproj
@@ -10,9 +10,10 @@
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/templates/project/Source/Program.cs b/templates/project/Source/Program.cs
index 18d4330..f2168cc 100644
--- a/templates/project/Source/Program.cs
+++ b/templates/project/Source/Program.cs
@@ -1,10 +1,17 @@
+using FastEndpoints.Security;
+using MyProject;
+
var bld = WebApplication.CreateBuilder(args);
bld.Services
- .AddFastEndpoints()
+ .AddAuthenticationJwtBearer(s => s.SigningKey = bld.Configuration["Auth:JwtKey"])
+ .AddAuthorization()
+ .AddFastEndpoints(o => o.SourceGeneratorDiscoveredTypes.AddRange(DiscoveredTypes.All))
.SwaggerDocument();
var app = bld.Build();
-app.UseFastEndpoints()
+app.UseAuthentication()
+ .UseAuthorization()
+ .UseFastEndpoints(c => c.Errors.UseProblemDetails())
.UseSwaggerGen();
app.Run();
diff --git a/templates/project/Source/Properties/launchSettings.json b/templates/project/Source/Properties/launchSettings.json
index 7c5a910..f2fb237 100644
--- a/templates/project/Source/Properties/launchSettings.json
+++ b/templates/project/Source/Properties/launchSettings.json
@@ -9,16 +9,6 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
- },
- "https": {
- "commandName": "Project",
- "dotnetRunMessages": true,
- "launchBrowser": true,
- "launchUrl": "swagger",
- "applicationUrl": "https://localhost:5001",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
}
}
-}
+}
\ No newline at end of file
diff --git a/templates/project/Source/appsettings.Development.json b/templates/project/Source/appsettings.Development.json
index 0c208ae..833a367 100644
--- a/templates/project/Source/appsettings.Development.json
+++ b/templates/project/Source/appsettings.Development.json
@@ -4,5 +4,8 @@
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
+ },
+ "Auth": {
+ "JwtKey": "a long secret string used to sign jwts. usually set via matching environment variable."
}
-}
+}
\ No newline at end of file
diff --git a/templates/project/Tests/SayHello/Tests.cs b/templates/project/Tests/SayHello/Tests.cs
index cd554a6..1ebfdd6 100644
--- a/templates/project/Tests/SayHello/Tests.cs
+++ b/templates/project/Tests/SayHello/Tests.cs
@@ -7,7 +7,7 @@ public class Tests(App App) : TestBase
[Fact, Priority(1)]
public async Task Invalid_User_Input()
{
- var (rsp, res) = await App.Client.POSTAsync(
+ var (rsp, res) = await App.Client.POSTAsync(
new()
{
FirstName = "x",
@@ -15,8 +15,8 @@ public async Task Invalid_User_Input()
});
rsp.StatusCode.Should().Be(HttpStatusCode.BadRequest);
- res.Errors.Count.Should().Be(2);
- res.Errors.Keys.Should().Equal("firstName", "lastName");
+ res.Errors.Count().Should().Be(2);
+ res.Errors.Select(e => e.Name).Should().Equal("firstName", "lastName");
}
[Fact, Priority(2)]
diff --git a/templates/project/Tests/Tests.csproj b/templates/project/Tests/Tests.csproj
index 7de7f09..d0f1502 100644
--- a/templates/project/Tests/Tests.csproj
+++ b/templates/project/Tests/Tests.csproj
@@ -8,16 +8,16 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
diff --git a/templates/test/Tests/Tests.csproj b/templates/test/Tests/Tests.csproj
index 3167d52..dd0a65e 100644
--- a/templates/test/Tests/Tests.csproj
+++ b/templates/test/Tests/Tests.csproj
@@ -9,11 +9,11 @@
-
+
-
-
-
+
+
+