Repository navigation
v5.33 Release
❇️ Help Keep FastEndpoints Free & Open-Source ❇️
Due to the current unfortunate state of FOSS, please consider becoming a sponsor and help us beat the odds to keep the project alive and free for everyone.
New 🎉
Migrate to xUnit v3 ⚠️
If you're using the FastEndpoints.Testing package in your test projects, take the following steps to migrate your projects:
- Update all "FastEndpoints" package references in your projects to "5.33.0".
- In your test project's
.csprojfile:- Remove the package reference to the
xunitv2 package. - Add a package reference to the new
xunit.v3library with version1.0.0 - Change the version of
xunit.runner.visualstudioto3.0.0
- Remove the package reference to the
- Build the solution.
- If there are compilation errors related to the return type of overridden methods in your derived
AppFixture<TProgram>classes, such asSetupAsyncandTearDownAsync. Change their return type fromTasktoValueTaskto resolve these errors. - If there are any compilation errors related to
XUnit.Abstractionsnamespace not being found, simply delete those "using statements" as that namespace has been removed in xUnit v3.
After doing the above, it should pretty much be smooth sailing, unless your project is affected by the removal of previously deprecated classes as mentioned in the "Breaking Changes" section below.
Eliminate the need for [BindFrom(...)] attribute
Until now, when binding from sources other than JSON body, you had to annotate request DTO properties with the [BindFrom("my_field")] attribute when the incoming field name is different to the DTO property name. A new setting has now been introduced which allows you to use the same property naming policy as the serializer for matching incoming request parameters without having to use any attributes.
app.UseFastEndpoints(c => c.Binding.UsePropertyNamingPolicy = true)This only applies to properties where you haven't specified the field names manually using an attribute such as [BindFrom(...)], [FromClaim(...)]. [FromHeader(...)] etc.
Control binding sources per DTO property
The default binding order is designed to minimize attribute clutter on DTO models. In most cases, disabling binding sources is unnecessary. However, for rare scenarios where a binding source must be explicitly blocked, you can now do the following:
[DontBind(Source.QueryParam | Source.RouteParam)]
public string UserID { get; set; } The opposite approach can be taken as well, by just specifying a single binding source for a property like so:
[FormField]
public string UserID { get; set; }
[QueryParam]
public string UserName { get; set; }
[RouteParam]
public string InvoiceID { get; set; }Deeply nested complex model binding from query parameters
Binding deeply nested complex DTOs from incoming query parameters is now supported. Please refer to the documentation here.
Swagger descriptions for deeply nested DTO properties
Until now, if you wanted to provide text descriptions for deeply nested request DTO properties, the only option was to provide them via XML document summary tags. You can now provide descriptions for deeply nested properties like so:
Summary(
s =>
{
s.RequestParam(r => r.Nested.Name, "nested name description");
s.RequestParam(r => r.Nested.Items[0].Id, "nested item id description");
});Descriptions for lists and arrays can be provided by using an index 0 to get at the actual property. Note: only lists and arrays can be used for this.
Fixes 🪲
Incorrect latest version detection with 'Release Versioning' strategy
The new release versioning strategy was not correctly detecting the latest version of an endpoint if there was multiple endpoints for the same route such as a GET & DELETE endpoint on the same route.
Issue with nullability context not being thread safe in Swagger processor
In rare occasions where swagger documents were being generated concurrently, an exception was being thrown due to NullabilityInfoContext not being thread safe. This has been fixed by implementing a caching mechanism per property type.
Complex DTO handling in routeless testing extensions
If the request DTO is a complex structure, testing with routeless test extensions like the following did not work correctly:
[Fact]
public async Task FormDataTest()
{
var book = new Book
{
BarCodes = [1, 2, 3],
CoAuthors = [new Author { Name = "a1" }, new Author { Name = "a2" }],
MainAuthor = new() { Name = "main" }
};
var (rsp, res) = await App.GuestClient.PUTAsync<MyEndpoint, Book, Book>(book, sendAsFormData: true);
rsp.IsSuccessStatusCode.Should().BeTrue();
res.Should().BeEquivalentTo(book);
}Incorrect detection of generic arguments of generic commands
There was a minor oversight in correctly detecting the number of generic arguments of generic commands if there was more than one.
This has been fixed to correctly detect all generic arguments of generic commands.
Complex form data binding issue
When binding deeply nested form data with the [FromForm] attribute, if a certain deeply nested objects didn't have at least one primitive type property, it would not get bound correctly. This has been fixed as well as the binding logic being improved.
Breaking Changes ⚠️
Removal of deprecated classes (Testing related)
After following the xUnit v3 upgrade instructions above, you may be affected by the removal of the following previously deprecated classes:
TestFixture<TProgram>: Use theAppFixture<TProgram>class instead.TestClass<TFixture>: Use theTestBase<TFixture>class instead.
Removal of constructor overloads from 'AppFixture<TProgram>'
Due to the migration to xUnit v3, the AppFixture<TProgram> base class no longer accepts IMessageSink and ITestOutputHelper arguments and only has a parameterless constructor.
Removal of undocumented [FromQueryParams] attribute
[FromQueryParams] was an undocumented feature that was put in place to help people migrating from old MVC projects to make the transition easier. It was not documented due to its extremely poor performance and we wanted to discourage people from using query parameters as a means to submit complex data structures.
The newly introduced [FromQuery] attribute can be used now if you really must send complex query parameters. However, it is not a one-to-one replacement as the query naming convention is quite strict and simplified.