Introduction
April 6, 2022 ยท View on GitHub
This repository is intended to aid in migrating API projects using JsonApiDotNetCore from earlier versions.
How to use
The release notes describe what has changed between versions. But to see the effects, this repository contains an example ASP.NET API project. By comparing the changes between branches in this repo, you can see how this example project was changed to work with the next major version.
Upgrade from v4 to v5
The diff for the upgrade of example project from v4.0.0 to v5.0.1 shows how to convert with minimal change in behavior. It includes tests that assert on the response json.
This upgrade should be straightforward in most cases. Notable renames:
| JsonApiDotNetCore v4 | JsonApiDotNetCore v5 |
|---|---|
IResourceContextProvider | IResourceGraph |
ResourceContext | ResourceType |
RelationshipAttribute.Left/RightType | RelationshipAttribute.Left/RightType.ClrType |
ErrorDocument | Document |
AtomicOperationsDocument | Document |
Error | ErrorObject |
Upgrade from v3 to v4
The diff for the upgrade of example project from v3.1.0 to v4.0.0 shows how to convert with minimal change in behavior. It includes tests that assert on the response json.
Since v3, a lot of the internal workings have been optimized. Depending on how much custom code you wrote, the next table of renames may help to find back what you need.
| JsonApiDotNetCore v3 | JsonApiDotNetCore v4 |
|---|---|
BaseJsonApiController.GetRelationshipAsync | .GetSecondaryAsync |
BaseJsonApiController.GetRelationshipsAsync | .GetRelationshipAsync |
EntityResourceService | JsonApiResourceService |
IEntityRepository | IResourceRepository |
DefaultEntityRepository | EntityFrameworkCoreRepository |
ResourceDefinition | JsonApiResourceDefinition |
ContextEntity | ResourceContext |
IContextGraph | IResourceGraph |
RequestMiddleware | JsonApiMiddleware |
IQueryParser | IQueryStringReader |
RelationshipAttribute.(Dependent)Type | RelationshipAttribute.RightType |
Constants.ContentType | HeaderConstants.MediaType |
IJsonApiContext replacement
To improve separation of concerns, IJsonApiContext has been refactored and no longer exists.
The table below lists which interfaces to inject, in order to obtain the same information.
IJsonApiContext Member | Replacement |
|---|---|
Options | IJsonApiOptions |
ResourceGraph | IResourceGraph |
QuerySet | IEnumerable<IQueryConstraintProvider> |
PageManager | IPaginationContext |
AttributesToUpdate, RelationshipsToUpdate | ITargetedFields |
HasOneRelationshipPointers, HasManyRelationshipPointers | ITargetedFields.Relationships[].GetValue() |
BasePath | IJsonApiRequest.BasePath |
RequestEntity | IJsonApiRequest.(SecondaryResource ?? PrimaryResource) |
DocumentMeta | IResponseMeta |
MetaBuilder | IResourceDefinition.GetMeta() |
IsRelationshipPath | IJsonApiRequest.Kind |
GenericProcessorFactory | IGenericServiceFactory |