Skip to content

v5.1.0

Compare
Choose a tag to compare
@bkoelman bkoelman released this 08 Nov 21:01
· 511 commits to master since this release

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