Releases: json-api-dotnet/JsonApiDotNetCore
v5.3.0
New features and enhancements
This release opens up query string parsing plus LINQ expression building for extensibility. This means that you can now define and plug in your own functions, available for use in query strings. Also, errors for invalid query string values now include the failure position, along with the ^ marker. See #1286 for details and examples.
Breaking changes
Related to the above, the query string parsers, LINQ builders, and RuntimeTypeConverter have been moved out of .Internal namespaces.
Bugfixes
- Do not execute unneeded SQL query in 1-to-1 relationship update, which fails on EF Core 8 preview.
- Query strings: do not allow comparison of
count()withnull; do not treatnullas a possible field name.
Merged PRs
- Package updates by @bkoelman in #1274
- Corrected HTTP method in updating.md by @boginw in #1278
- Remove workaround for RSRP-491451 by @bkoelman in #1276
- Add sponsor credits by @bkoelman in #1292
- Fix exception thrown by EF Core 8 preview by @bkoelman in #1289
- Extensible query string functions by @bkoelman in #1286
New Contributors
Full Changelog: v5.2.0...v5.3.0
v5.2.0
Enhancements
- Improve resource change tracking performance.
- Improve performance of response serialization for large number of included resources.
- Auto-feed includes from query string to the serializer when custom resource service is used.
- Refreshed examples: connection strings, API namespaces, seed with sample data, use
longIDs, detailed logging.- NoEntityFrameworkExample now uses a hardcoded in-memory dataset, demonstrating how to implement a custom read-only resource service and resource repository, which compiles the produced LINQ query and executes it against the dataset.
- Harden Attr/Relationship attributes against invalid input.
- Updated Ember sample to use latest versions and include tests. Special thanks to @briarsweetbriar and @rtablada!
Bugfixes
- On secondary endpoint, the incoming filter from query string was not applied when determining total resource count via inverse relationship.
- A duplicate trailing slash was rendered in
Locationheader when request path ended with a slash. - Minor corrections in documentation.
- Do not emit unused namespace import in controller source generator.
- Use deterministic culture when converting to string.
- Fixes for using
includeandfieldswith EF Core owned entities.
Breaking changes
- Minor changes in the
QueryExpressionmodel shape, to make it easier to understand and consume. - Removed resource ID from error message, as the error is unrelated to any specific record.
- Disable EF Core Change Tracking on read-only requests (can be reverted by overriding a virtual method on the resource repository).
Merged PRs
- Fixed: incorrect meta:total on secondary endpoint with filter by @bart-vmware in #1259
- Query tweaks by @bkoelman in #1257
- Fix namespace imports in controller source generator by @bkoelman in #1261
- Improve serializer performance by @bkoelman in #1265
- Use deterministic culture when converting to string by @bkoelman in #1267
- Update examples by @bkoelman in #1269
- Harden Attr/Relationship attributes against invalid input by @bkoelman in #1268
- Fixes for EF Core owned entities by @bkoelman in #1272
Full Changelog: v5.1.2...v5.2.0
v5.1.2
Enhancements
- New documentation sections: FAQ and Common Pitfalls.
- Entity Framework Core 7 table-per-concrete-type (TPC) inheritance is now supported.
- Added support for DateOnly and TimeOnly. This works out of the box when using .NET 7. But when using .NET 6, additional steps are required.
- Support for
[ApiController]has improved, though its use is not recommended because it degrades JSON:API compliance. Therefore we now log a warning when found.
Bugfixes
- Fixed whitespace handling in query string parameters.
- Fixed ModelState validation in atomic operations when using custom validators with injected dependencies.
- Fixed incorrect ModelState validation error when using
[Range]that does not include the type's default value.
Breaking changes
- Parsing query string parameters used to rely on the current culture, which is no longer the case. To revert to the old behavior, add the following at startup:
AppContext.SetSwitch("JsonApiDotNetCore.ParseQueryStringsUsingCurrentCulture", true);
Merged PRs
- Fix missing HttpContext on ValidationContext during atomic operations by @Tommy228 in #1251
- Better handling of [ApiController] usage by @bkoelman in #1246
- Package updates; run tests against EF Core 7 by @bkoelman in #1249
- Fixed: fail on non-leading whitespace in field chains by @bkoelman in #1252
- Fixed: ModelState validation failed when [Range] does not include property default value by @bkoelman in #1253
- Documentation: FAQ and Common Pitfalls by @bkoelman in #1245
- Add support for DateOnly/TimeOnly by @bkoelman in #1169
New Contributors
- @Tommy228 made their first contribution in #1251
Full Changelog: v5.1.1...v5.1.2
v5.1.1
This patch relaxes the requirements for the any() filter function: Instead of requiring at least two constants, now a single constant works as well.
Merged PRs
Full Changelog: v5.1.0...v5.1.1
v5.1.0
New features and enhancements
The final version of JSON:API v1.1 was released recently, eight years after its initial draft. We've always tried to keep up-to-date with specification changes, and this release follows that tradition. We've slightly adapted JsonApiDotNetCore in corner cases (#1195 and #1196) where the specification used to be ambiguous.
New in this release: capabilities for relationships. Similar to [Attr(Capabilities = ...)], you can now declare what's permitted in requests where relationships are involved: [HasOne(HasOneCapabilities = ...)] and set the default in options. Despite this was already possible by writing custom code in resource definitions (which can still be useful when depending on externally changing conditions), relationship capabilities are just a shorthand for simpler cases. See its documentation and feature design for details.
Based on our own research and experiments, we've updated the guidance on mapping Entity Framework Core one-to-one relationships at https://www.jsonapi.net/usage/resources/relationships.html#one-to-one-relationships-in-entity-framework-core to make JsonApiDotNetCore work properly. In summary, there are two pitfalls to watch out for, where you need to override the default mappings: identifying foreign keys and using DeleteBehavior.SetNull instead of the misleading default DeleteBehavior.ClientSetNull.
You can now share your models (that is, your Entity Framework Core entity classes that are decorated with JsonApiDotNetCore attributes) with .NET Framework code. To accomplish this, move them into a separate, shared project that references only the JsonApiDotNetCore.Annotations package. Aside from targeting .NET Standard 1.0 instead of .NET 6, we've fixed #1198 and #1199.
Breaking changes
Related to the above, we've obsoleted CanInclude on relationships. The equivalent functionality is now covered by relationship capabilities.
Merged PRs
- Multi-target Annotations against .NET Standard 1.0 by @bkoelman in #1192
- Improve error message when duplicate controllers found by @bkoelman in #1193
- Relationship capabilities and bugfixes by @bkoelman in #1197
- Update EF Core docs for one-to-one relationships by @bkoelman in #1207
- Updated example to match with current implementation by @bkoelman in #1208
Full Changelog: v5.0.3...v5.1.0
v5.0.3
This patch removes a limitation that blocked future use of EF Core 7, as well as minor tweaks and optimizations.
Merged PRs
- Minor serialization tweaks by @bkoelman in #1170
- Remove dependency on EF Core "Issue26779" AppContext switch by @bkoelman in #1176
- Add
// <auto-generated />comment to source-generated controllers by @bkoelman in #1178
Full Changelog: v5.0.2...v5.0.3
v5.0.2
v5.0.1
v5.0.0
New features and enhancements
In addition to what's listed at v5.0.0-pre1, this release adds full support for resource inheritance. In short, this means you can define (abstract) base resource classes and perform various operations against their endpoints. Sparse fieldsets, includes, sorting and filtering were adapted to understand them, among which is the new isType() filter function. When using post/patch/delete in a type hierarchy, extra database queries are executed to provide the best possible experience for writing custom business logic in resource definitions. For details, see documentation at https://www.jsonapi.net/usage/resources/inheritance.html and the PR description. Additionally, this release improves serialization performance and makes resource graph lookups faster.
Note: See our updated documentation, as well as updated examples in our codebase.
Upgrading from v4 instead? Be sure to check out our migration guide.
Breaking changes
Aside from the breaking changes listed at v5.0.0-pre1, we had to slightly adapt some signatures in resource service/repository/definition interfaces to support resource inheritance. And we fixed the bug where we forgot to call into IResourceDefinition.OnPrepareWrite from a delete to-many relationship request.
Merged PRs
- Fixed: do not auto-register abstract base classes and interfaces by @bart-degreed in b17f8f5
- Added example that uses a different database per tenant by @bart-degreed in #1135
- Added workaround for bug in EF Core 6.0.2 by @bart-degreed in #1139
- Bugfix: hide Self link in included resources for missing controller by @bart-degreed in #1141
- Replaced references to Error in docs, which was renamed to ErrorObject by @bart-degreed in #1143
Full Changelog: v4.2.0...v5.0.0
v5.0.0-pre1
New features and enhancements
First of all, this release is a refresher to embrace the latest technologies. We've updated to ASP.NET 6 with EF Core 6 and adopted nullable reference types. We've switched to System.Text.Json. And we're now leveraging EF Core's built-in many-to-many relationships. Lastly, ASP.NET controllers can be auto-generated using source generators. Aside from these changes, pagination links at secondary endpoints got better. We've added various performance optimizations. And improved error responses on invalid input. And quite some bug fixes too!
Note: See our updated documentation, as well as updated examples in our codebase.
Upgrading from v4 instead? Be sure to check out our migration guide.
Breaking changes
- When using
[Resource], this now automatically generates a controller class. Replace with[Resource(GenerateControllerEndpoints = JsonApiEndpoints.None)]to turn that off. - The experimental Resource Hooks feature has finally been removed.
- The switch to System.Text.Json introduced breaks as well, see here and here.
- Short-hand interfaces were removed too.
- Remaining breaks are listed here, here and here.
Merged PRs
- Removed Resource Hooks by @bart-degreed in #1036
- Updated dependencies to .NET 5 with EF Core 5 by @bart-degreed in #1022
- Updated roadmap for v5.x by @bart-degreed in #1034
- Native many to many by @bart-degreed in #1037
- Refactorings by @bart-degreed in #1038
- Instrumented code to measure execution time of the various layers by @bart-degreed in #1023
- Optimized RemoveFromToManyRelationship endpoint by @bart-degreed in #1039
- Feature/allow leading space by @sgryphon in #1041
- Rename JsonApiDotNetCoreExampleTests -> JsonApiDotNetCoreTests by @maurei in #1069
- Removing dependency on JsonApiDotNetCoreExample project in test projects by @maurei in #1068
- Updated PostgreSQL to v13.4 by @bart-degreed in #1072
- Removed temporary workaround to start postgres service in cibuild by @bart-degreed in #1083
- Restored docs for HasManyThrough, which was removed in #1037 by @bart-degreed in #1084
- Use System.Text.Json by @bart-degreed in #1075
- Corrected example in docs by @bart-degreed in #1087
- Redesign conversion between JSON objects and ASP.NET models by @bart-degreed in #1091
- Remove short-hand interfaces for TId is int by @bart-degreed in #1093
- Nullable reference types by @bart-degreed in #1095
- Secondary paging by @bart-degreed in #1100
- Resource Graph validations by @bart-degreed in #1101
- Fix code cleanup by @bart-degreed in #1107
- Various fixes and improvements by @bart-degreed in #1114
- Auto-generated JSON:API controllers using source generators by @bart-degreed in #1117
- Update to .NET 6 with EF Core 6 by @bart-degreed in #1122
- Added tests for blobs by @bart-degreed in #1125
- Move resource annotations into separate package by @bart-degreed in #1127
New Contributors
Full Changelog: v4.2.0...v5.0.0-pre1