Repository navigation
Releases
v5.12.0
New features and enhancements
This release brings the following minor convenience changes:
- Errors in multiple query string parameters are now aggregated (instead of returning only the first error).
- A new method is provided to suppress the "does not implement 'IIdentifiable'" warning for
DbContextentities that can't be annotated with[NoResource]because they are defined in a third-party assembly (typically the entities from ASP.NET Core Identity).
Example usage:builder.Services.AddJsonApi<AppDbContext>(resources: resourceGraphBuilder => resourceGraphBuilder.SuppressWarningNotIdentifiable<IdentityRole>());
- Deleting a resource from an optional one-to-one relationship is now fully working on SQL Server, even in complex database models with multiple foreign keys, cyclic dependencies, etc. This fixes errors like:
update or delete on table "(table_name)" violates foreign key (fk_name).JsonApiDotNetCore now scans the foreign key dependency tree in theDbContextmodel and loads all the needed related entities in the change tracker upfront, so that EF Core can issue update statements (setting remote foreign keys tonull) before deletion. - Transient failures in atomic:operations transactions are now retryable. This is opt-in for regular API projects, while enabled by default in Aspire projects.
- DapperExample was updated to support
Microting.EntityFrameworkCore.MySqlto create the database, aside from the abandoned Pomelo NuGet package.
Breaking changes
- As announced in #2059, we discontinued OpenAPI support and deprecated its experimental packages.
- The entity mappings in your
DbContextfor publicly exposed resource types are now validated for common pitfalls:ClientSetNull(except for SQL Server) and Identifying FKs. You can downgrade the new startup error to logged warnings by settingThrowForProblematicEntityMappingstofalseinAddJsonApi()options. - To support retryable transactions, the public
IOperationsTransactionFactoryinterface has changed. - The dependency on Ben.Demystifier has been removed because built-in exception stack traces have improved over the years, and this package is no longer maintained.
Bugfixes
- When a transaction commit failed in an atomic:operations request, the source pointer in the error response was incorrect.
Merged PRs
- Remove OpenAPI support by @bkoelman in #2065
- Add Dapper support for Microting.EntityFrameworkCore.MySql by @bkoelman in #2076
- Use Docker Compose to start containers by @bkoelman in #2077
- Aggregate all query string errors in response by @bkoelman in #2084
- Add ResourceGraphBuilder.SuppressWarningNotIdentifiable() by @rghvgrv in #2092
- Validate entity model and support optional one-to-one relationships on SQL Server by @bkoelman in #2090
- Retryable transactions by @bkoelman in #2098
New Contributors
Full Changelog: v5.11.0...v5.12.0
v5.11.0
New features and enhancements
This release adds more ways to use functions in filter query strings (see #1881). Additionally, the request pipeline is optimized to eliminate COUNT(*) SQL queries when pagination is disabled, while the new JsonApiResourceService.CanIncludeTotalResourceCount virtual method enables skipping these SQL queries based on additional user-defined logic.
OpenAPI preview 8 comes with support for [DisableQueryString] and [HasMany(DisablePagination = true)].
Breaking changes
- As a result of request pipeline optimization, the order in which resource definition callbacks execute has changed slightly (see #1915).
- The incorrect
[DisallowNull]on theidparameter ofIResourceWriteRepository.GetForCreateAsynchas been removed. - The relaxed variants of JSON:API media types have been deprecated, now that both NSwag and Kiota can properly handle JSON:API extensions. While they are still accepted, they are no longer emitted when generating OpenAPI documents. Our extension spec has been updated.
Bugfixes
- Fixed an incorrect
HTTP 415response in content negotiation with JSON:API extensions. - When the
AllowViewcapability onHasOneis turned off,HTTP GETrequests to secondary/relationship endpoints are now blocked. - OpenAPI: Links for
filter/page/sortare no longer generated for endpoints that return a single resource/identifier. - OpenAPI: Not all relationship capabilities were properly reflected in the generated OpenAPI document.
Merged PRs
- Replace int with long for ID by @niteshsinghal85 in #1879
- Greater flexibility in custom filter functions by @bkoelman in #1881
- Fixes to doc-comments to improve layout of generated API documentation by @bkoelman in #1902
- Request meta tests boilerplate by @mrmarcosmagalhaes in #1746
- Optimization: skip COUNT query when pagination is disabled by @bkoelman in #1915
- Fix awkward grammar by @bkoelman in #1918
- Document JsonApiEndpoints enum by @bkoelman in #1304
- OpenAPI: Add support for DisableQueryString/DisablePagination and fix links by @bkoelman in #1924
- Minor performance improvements on hot code paths by @bkoelman in #1947
- Deprecate relaxed variants of media types by @bkoelman in #1966
- Fixed: HTTP 415 error at operations endpoint when using OpenAPI extension by @bkoelman in #1971
- Refactor: use HttpMethods by @bkoelman in #1976
- Block GET request on secondary/relationship endpoint when
AllowViewis off by @bkoelman in #1992 - Add OpenAPI test coverage for capabilities by @bkoelman in #1993
- Add OpenAPI tests for the presence of meta by @bkoelman in #1996
- Nullability fixes by @bkoelman in #2006
- Add OpenAPI tests for custom routes by @bkoelman in #2008
- Add virtual CanIncludeTotalResourceCount to JsonApiResourceService by @bjornharrtell in #2005
New Contributors
- @niteshsinghal85 made their first contribution in #1879
- @mrmarcosmagalhaes made their first contribution in #1746
Full Changelog: v5.10.0...v5.11.0
v5.10.0
New features and enhancements
This release adds support for .NET 10 and Entity Framework Core 10.
OpenAPI preview 7 can now produce OpenAPI 3.1 documents:
builder.Services.Configure<SwaggerOptions>(options =>
options.OpenApiVersion = OpenApiSpecVersion.OpenApi3_1);Merged PRs
- Add OpenAPI tests for using various attribute data types by @bkoelman in #1832
- Added support for EF Core 10 on .NET 10 by @bkoelman in #1853
Full Changelog: v5.9.1...v5.10.0
v5.9.1
This patch lowers the minimally required version of Microsoft.CodeAnalysis from 4.13.0 to 4.8.0, to enable building projects with older .NET 8 SDK versions on Ubuntu. The assembly is used to generate controller classes at compile time.
There's no need to update, unless you get build warnings similar to the following:
CSC : warning CS9057: The analyzer assembly '/path/to/JsonApiDotNetCore.SourceGenerators.dll' references version '4.13.0.0' of the compiler, which is newer than the currently running version '4.12.0.0'.
Merged PRs
Full Changelog: v5.9.0...v5.9.1
v5.9.0
New features and enhancements
This release enables the use of derived relationships in query strings for all query string parameters; what used to work only for include, now also works for filter[], sort[], and page.
The sample for using obfuscated IDs has been updated to include atomic operations, and it uses the new [HideResourceIdTypeInOpenApi] to show IDs as string in OpenAPI.
The controller source generator has been updated to use the newer incremental API, improving IDE responsiveness in large solutions.
OpenAPI preview 5 includes the following fixes and enhancements:
- Custom action methods in JSON:API controllers now show up in OpenAPI.
- Fixed a crash that could occur with specific relationship naming patterns.
- An exception is thrown at startup if you forgot to update our OpenAPI NuGet package.
Breaking changes
- The new source generator requires a recent version of the .NET SDK to build your project.
Merged PRs
- Allow derived inclusion chains in filter/sort/page query strings by @bkoelman in #1756
- Improved ID obfuscation by @bkoelman in #1775
- Fixed crash where the OpenAPI atomic:operations discriminator key isn't unique per schema ID by @bkoelman in #1776
- Fixes and optimizations in ToString() calls by @bkoelman in #1780
- Add OpenAPI support for custom JSON:API action methods by @bkoelman in #1787
- Switch to incremental source generator API by @bkoelman in #1814
- Throw at startup when different OpenAPI version is loaded by @bkoelman in #1819
Full Changelog: v5.8.1...v5.9.0
v5.8.1
This patch fixes the following crash at startup:
System.IO.FileNotFoundException: 'Could not load file or assembly 'JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325'. The system cannot find the file specified.'
Merged PRs
- Fix roundtrip of Parse/ToString for include query string parameters by @bkoelman in #1754
- Revert package update of JetBrains.Annotations by @bkoelman in #1755
Full Changelog: v5.8.0...v5.8.1
v5.8.0
Since we fixed the bug in v5.7.0 where pagination was not applied on included derived types, we received reports of slow query performance for complex queries on type hierarchies. This release provides various optimizations to address the problem:
- When pagination is turned off, implicit sort by ID is no longer added to the query.
- Redundant selectors are eliminated from the final query.
- Pagination can be turned off per relationship using
[HasMany(DisablePagination = true)], which overrules global settings.
OpenAPI preview 3 includes the following fixes and enhancements:
- Non-JSON:API endpoints (both Controllers and Minimal APIs) are now included in the OpenAPI document.
- Calling
AddOpenApiForJsonApi()no longer changes the expected content type for regular JSON:API requests. - Improved error when
AddJsonApi()/AddOpenApiForJsonApi()aren't called in the expected order. - Refactored an internal workaround to support
dotnet swagger, such that the workaround is no longer needed. - Fixed error when concurrent requests download the OpenAPI document.
Merged PRs
- Log QueryLayer and LINQ expression at Debug level by @bkoelman in #1732
- Reduce complexity of QueryLayer after composition by @bkoelman in #1735
- Throw when AddOpenApiForJsonApi is called before AddJsonApi by @bkoelman in #1737
- Add note on included and pagination by @bjornharrtell in #1744
- OpenAPI: Show custom endpoints, fix content negotiation by @bkoelman in #1747
- OpenAPI tweaks and fixes by @bkoelman in #1748
- Enable to force-disable pagination per relationship by @bkoelman in #1750
Full Changelog: v5.7.1...v5.8.0
v5.7.1
This patch:
- Fixes a build error when using Kiota without any OpenAPI references.
- Fixes compatibility with MongoDB.
- Removes the Experimental attribute from the
AddOpenApiForJsonApiextension method. - Reverts an unintentional binary breaking change in
QueryTokenizer.
Merged PRs
- Publish packages to feedz.io by @bkoelman in #1719
- Improve detection of collection element type by @bkoelman in #1720
- Fixed: build error after adding reference to JADNC.Kiota package by @bkoelman in #1721
- Remove Experimental attribute from AddOpenApiForJsonApi by @bkoelman in #1724
Full Changelog: v5.7.0...v5.7.1
v5.7.0
New features and enhancements
After years of work, we're finally ready to ship the first preview release of OpenAPI support for JSON:API!
Now you can generate a documentation website from your models. And generate typed client libraries using NSwag and Microsoft Kiota. See the documentation to get started. In this preview, all JsonApiDotNetCore features work with OpenAPI, except for the following:
- Custom controllers and custom action methods are ignored.
- Controllers that use ID obfuscation don't work.
- The usage of
[DisableQueryString]on controllers is ignored.
As part of the OpenAPI work, basic support for third-party JSON:API extensions was added. We also introduced our own extension to enhance the OpenAPI experience.
Next to the existing IAtomicOperationFilter, IJsonApiEndpointFilter was added, which enables to remove controller action methods at runtime.
Breaking changes
- This version requires .NET 8 or higher, because official support for .NET 6 has ended.
- Properties on
HeaderConstantshave been obsoleted; see their message for the replacement. - The relaxed form "atomic-operations" for the Atomic Operations JSON:API extension was renamed to "atomic" for consistency.
Bugfixes
- A proper error is now returned when the ID in a request body is an empty string or whitespace.
- Resource inheritance: Atomic operations enabled on a base type are implicitly enabled on all derived types.
- Resource inheritance: Pagination on included derived types wasn't being applied.
- Resource inheritance: A post-resource request with
?includeused to fail. - The calculation of the total resource count on a secondary/relationship endpoint could crash when resource definitions are involved.
Merged PRs
- Fixed: Produce error on invalid ID in request body by @bkoelman in #1593
- Basic support for third-party JSON:API extensions by @bkoelman in #1623
- Fix resource inheritance with atomic operations by @bkoelman in #1628
- Refactorings for JSON:API extensions to unblock OpenAPI support by @bkoelman in #1629
- Resource inheritance fixes by @bkoelman in #1641
- Content negotiation: Enable override of chosen media type when Accept header is missing by @bkoelman in #1644
- IJsonApiEndpointFilter: remove controller action methods at runtime by @bkoelman in #1646
- Drop support for .NET 6, test against .NET 9 by @bkoelman in #1656
- Breaking: rename relaxed form of Atomic Operations extension by @bkoelman in #1664
- Add note about shared models by @bkoelman in #1679
- Refactor internal-only JSON:API extensions support by @bkoelman in #1687
- Marshall JsonApiException thrown from JsonConverter by @bkoelman in #1690
- Fix invalid expression for total count on inverse relationship filter from resource definition by @bkoelman in #1711
- Merge experimental OpenAPI support into master by @bkoelman in #1716
Full Changelog: v5.6.0...v5.7.0
v5.6.0
New features and enhancements
Aside from a new logo (which was needed to enable dark mode on the documentation website), most of the changes involve unblocking our ongoing development of OpenAPI support for JSON:API. Please read the docs and give it a try (see the instructions for NSwag and Kiota), we'd love to hear your feedback.
- The
describedbytop-level link has been added, whose visibility can be configured at various levels. Its value can be set by implementingIDocumentDescriptionLinkProvider. - Controller action methods have been enriched with
[Required], pipeline methods with[DisallowNull]foridparameters. - A relaxed variant of the atomic operations media type can be used, to workaround deficiencies in OpenAPI client generators.
Breaking changes
- When your project contains an atomic operations controller, earlier versions would always expose all operations for all resource types, despite the use of
[Resource(GenerateControllerEndpoints = ...)]to constrain endpoints. The new behavior is to block operations whose endpoints are blocked usingGenerateControllerEndpoints. If you're using custom controllers (or just want to override this default), implementIAtomicOperationFilter. To revert to the old behavior, useIAtomicOperationFilter.AlwaysEnabled.
Bugfixes
- Fix crash on empty query string parameter name. For example:
http://localhost:5065/people?=. - Fix percent-encoding of whitespace in response links. For example:
equals(city,%27New York%27)equals(city,%27New%20York%27). - Return empty object (
{}) instead of{ "data": null }in atomic operation results. - Do not allow
lidin atomic operations request when a client-generated ID is required. - Take
options.UseRelativeLinksinto account when rendering HTTP Location header.
Merged PRs
- Replace CreateTupleAccessExpressionForConstant with simpler implementation by @bkoelman in #1469
- Don't crash on empty query string parameter name by @verdie-g in #1484
- Drop dependency on EF Core internals by @bkoelman in #1492
- Enable setting the "describedby" top-level link by @bkoelman in #1495
- Controller attribute changes by @bkoelman in #1503
- Move back [FromBody] and [Required] to derived controllers by @bkoelman in #1506
- Move [FromBody] back on base controllers, to prevent a breaking change by @bkoelman in #1508
- Revert "Resharper: Replace async method with Task return" by @bkoelman in #1513
- Add support for configuring the visibility of the "describedby" link by @bkoelman in #1516
- Fix whitespace in query string parameters within pagination links by @bkoelman in #1526
- New logo, dark mode on landing page by @bkoelman in #1549
- Allow relaxed Content-Type for atomic operations by @bkoelman in #1553
- Filter operations based on GenerateControllerEndpoints usage by @bkoelman in #1561
- Return Forbidden when operation is inaccessible, to match resource endpoint status code by @bkoelman in #1562
- Fixed: return empty object instead of data:null in operation results by @bkoelman in #1564
- Fixed: Do not allow the use of 'lid' when client-generated IDs are required by @bkoelman in #1581
- Fixed: send absolute/relative URL in location header, depending on options.UseRelativeLinks by @bkoelman in #1582
- Add [DisallowNull] on TId in pipeline parameters by @bkoelman in #1583
Full Changelog: v5.5.1...v5.6.0