File tree Expand file tree Collapse file tree 5 files changed +21
-50
lines changed Expand file tree Collapse file tree 5 files changed +21
-50
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,6 @@ public static void AddJsonApiInternals(
129129 services . AddScoped < IJsonApiWriter , JsonApiWriter > ( ) ;
130130 services . AddScoped < IJsonApiDeSerializer , JsonApiDeSerializer > ( ) ;
131131 services . AddScoped < IJsonApiReader , JsonApiReader > ( ) ;
132- services . AddScoped < IJsonApiOperationsReader , JsonApiOperationsReader > ( ) ;
133132 services . AddScoped < IGenericProcessorFactory , GenericProcessorFactory > ( ) ;
134133 services . AddScoped ( typeof ( GenericProcessor < > ) ) ;
135134 services . AddScoped ( typeof ( GenericProcessor < , > ) ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ public Task<InputFormatterResult> ReadAsync(InputFormatterContext context)
3636 try
3737 {
3838 var body = GetRequestBody ( context . HttpContext . Request . Body ) ;
39+
3940 var model = _jsonApiContext . IsRelationshipPath ?
4041 _deSerializer . DeserializeRelationship ( body ) :
4142 _deSerializer . Deserialize ( body ) ;
@@ -67,4 +68,4 @@ private string GetRequestBody(Stream body)
6768 }
6869 }
6970 }
70- }
71+ }
Original file line number Diff line number Diff line change 55using JsonApiDotNetCore . Internal ;
66using JsonApiDotNetCore . Internal . Generics ;
77using JsonApiDotNetCore . Models ;
8+ using JsonApiDotNetCore . Models . Operations ;
89using JsonApiDotNetCore . Services ;
910using Newtonsoft . Json ;
1011using Newtonsoft . Json . Linq ;
@@ -28,7 +29,20 @@ public object Deserialize(string requestBody)
2829 {
2930 try
3031 {
31- var document = JsonConvert . DeserializeObject < Document > ( requestBody ) ;
32+ // TODO: determine whether or not the token should be re-used rather than performing full
33+ // deserialization again from the string
34+ var bodyJToken = JToken . Parse ( requestBody ) ;
35+ if ( bodyJToken . SelectToken ( "operations" ) != null )
36+ {
37+ var operations = JsonConvert . DeserializeObject < OperationsDocument > ( requestBody ) ;
38+ if ( operations == null )
39+ throw new JsonApiException ( 400 , "Failed to deserialize operations request." ) ;
40+
41+ return operations ;
42+ }
43+
44+ var document = bodyJToken . ToObject < Document > ( ) ;
45+
3246 _jsonApiContext . DocumentMeta = document . Meta ;
3347 var entity = DocumentToObject ( document . Data ) ;
3448 return entity ;
@@ -63,7 +77,7 @@ public List<TEntity> DeserializeList<TEntity>(string requestBody)
6377 try
6478 {
6579 var documents = JsonConvert . DeserializeObject < Documents > ( requestBody ) ;
66-
80+
6781 var deserializedList = new List < TEntity > ( ) ;
6882 foreach ( var data in documents . Data )
6983 {
Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
33using System . Threading . Tasks ;
4+ using JsonApiDotNetCore . Data ;
45using JsonApiDotNetCore . Internal ;
5- using JsonApiDotNetCore . Models ;
66using JsonApiDotNetCore . Models . Operations ;
77using JsonApiDotNetCore . Models . Pointers ;
88using Microsoft . EntityFrameworkCore ;
@@ -21,10 +21,10 @@ public class OperationsProcessor : IOperationsProcessor
2121
2222 public OperationsProcessor (
2323 IOperationProcessorResolver processorResolver ,
24- DbContext dbContext )
24+ IDbContextResolver dbContextResolver )
2525 {
2626 _processorResolver = processorResolver ;
27- _dbContext = dbContext ;
27+ _dbContext = dbContextResolver . GetContext ( ) ;
2828 }
2929
3030 public async Task < List < Operation > > ProcessAsync ( List < Operation > inputOps )
You can’t perform that action at this time.
0 commit comments