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 v4JsonApiDotNetCore v5
IResourceContextProviderIResourceGraph
ResourceContextResourceType
RelationshipAttribute.Left/RightTypeRelationshipAttribute.Left/RightType.ClrType
ErrorDocumentDocument
AtomicOperationsDocumentDocument
ErrorErrorObject

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 v3JsonApiDotNetCore v4
BaseJsonApiController.GetRelationshipAsync.GetSecondaryAsync
BaseJsonApiController.GetRelationshipsAsync.GetRelationshipAsync
EntityResourceServiceJsonApiResourceService
IEntityRepositoryIResourceRepository
DefaultEntityRepositoryEntityFrameworkCoreRepository
ResourceDefinitionJsonApiResourceDefinition
ContextEntityResourceContext
IContextGraphIResourceGraph
RequestMiddlewareJsonApiMiddleware
IQueryParserIQueryStringReader
RelationshipAttribute.(Dependent)TypeRelationshipAttribute.RightType
Constants.ContentTypeHeaderConstants.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 MemberReplacement
OptionsIJsonApiOptions
ResourceGraphIResourceGraph
QuerySetIEnumerable<IQueryConstraintProvider>
PageManagerIPaginationContext
AttributesToUpdate, RelationshipsToUpdateITargetedFields
HasOneRelationshipPointers, HasManyRelationshipPointersITargetedFields.Relationships[].GetValue()
BasePathIJsonApiRequest.BasePath
RequestEntityIJsonApiRequest.(SecondaryResource ?? PrimaryResource)
DocumentMetaIResponseMeta
MetaBuilderIResourceDefinition.GetMeta()
IsRelationshipPathIJsonApiRequest.Kind
GenericProcessorFactoryIGenericServiceFactory