Skip to content

Commit 2302fcb

Browse files
committed
chore: fix merge
2 parents b8e628d + f22d932 commit 2302fcb

File tree

106 files changed

+977
-1142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+977
-1142
lines changed

src/Examples/GettingStarted/Controllers/ArticlesController.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ public class ArticlesController : JsonApiController<Article>
1010
{
1111
public ArticlesController(
1212
IJsonApiOptions jsonApiOptions,
13-
IResourceGraph resourceGraph,
1413
IResourceService<Article> resourceService)
15-
: base(jsonApiOptions, resourceGraph, resourceService)
14+
: base(jsonApiOptions, resourceService)
1615
{ }
1716
}
1817
}

src/Examples/GettingStarted/Controllers/PeopleController.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ public class PeopleController : JsonApiController<Person>
1010
{
1111
public PeopleController(
1212
IJsonApiOptions jsonApiOptions,
13-
IResourceGraph resourceGraph,
1413
IResourceService<Person> resourceService)
15-
: base(jsonApiOptions, resourceGraph, resourceService)
14+
: base(jsonApiOptions, resourceService)
1615
{ }
1716
}
1817
}

src/Examples/GettingStarted/ResourceDefinitionExample/ModelDefinition.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace GettingStarted.ResourceDefinitionExample
66
{
77
public class ModelDefinition : ResourceDefinition<Model>
88
{
9-
public ModelDefinition(IResourceGraph graph) : base(graph)
9+
public ModelDefinition(IContextEntityProvider provider) : base(provider)
1010
{
1111
}
1212

src/Examples/GettingStarted/ResourceDefinitionExample/ModelsController.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ public class ModelsController : JsonApiController<Model>
99
{
1010
public ModelsController(
1111
IJsonApiOptions jsonApiOptions,
12-
IResourceGraph resourceGraph,
1312
IResourceService<Model> resourceService)
14-
: base(jsonApiOptions, resourceGraph, resourceService)
13+
: base(jsonApiOptions, resourceService)
1514
{ }
1615
}
1716
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using JsonApiDotNetCore.Configuration;
22
using JsonApiDotNetCore.Controllers;
3-
using JsonApiDotNetCore.Internal.Contracts;
43
using JsonApiDotNetCore.Services;
54
using JsonApiDotNetCoreExample.Models;
65

@@ -10,9 +9,8 @@ public class ArticlesController : JsonApiController<Article>
109
{
1110
public ArticlesController(
1211
IJsonApiOptions jsonApiOptions,
13-
IResourceGraph resourceGraph,
1412
IResourceService<Article> resourceService)
15-
: base(jsonApiOptions, resourceGraph, resourceService)
13+
: base(jsonApiOptions, resourceService)
1614
{ }
1715
}
1816
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using JsonApiDotNetCore.Configuration;
22
using JsonApiDotNetCore.Controllers;
3-
using JsonApiDotNetCore.Internal.Contracts;
43
using JsonApiDotNetCore.Services;
54
using JsonApiDotNetCoreExample.Models;
65
using Microsoft.Extensions.Logging;
@@ -11,10 +10,9 @@ public class CamelCasedModelsController : JsonApiController<CamelCasedModel>
1110
{
1211
public CamelCasedModelsController(
1312
IJsonApiOptions jsonApiOptions,
14-
IResourceGraph resourceGraph,
1513
IResourceService<CamelCasedModel> resourceService,
1614
ILoggerFactory loggerFactory)
17-
: base(jsonApiOptions, resourceGraph, resourceService, loggerFactory)
15+
: base(jsonApiOptions, resourceService, loggerFactory)
1816
{ }
1917
}
2018
}

src/Examples/JsonApiDotNetCoreExample/Controllers/PassportsController.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using JsonApiDotNetCore.Configuration;
22
using JsonApiDotNetCore.Controllers;
3-
using JsonApiDotNetCore.Internal.Contracts;
43
using JsonApiDotNetCore.Services;
54
using JsonApiDotNetCoreExample.Models;
65
using Microsoft.Extensions.Logging;
@@ -9,7 +8,10 @@ namespace JsonApiDotNetCoreExample.Controllers
98
{
109
public class PassportsController : JsonApiController<Passport>
1110
{
12-
public PassportsController(IJsonApiOptions jsonApiOptions, IResourceGraph resourceGraph, IResourceService<Passport, int> resourceService, ILoggerFactory loggerFactory = null) : base(jsonApiOptions, resourceGraph, resourceService, loggerFactory)
11+
public PassportsController(IJsonApiOptions jsonApiOptions,
12+
IResourceService<Passport, int> resourceService,
13+
ILoggerFactory loggerFactory = null)
14+
: base(jsonApiOptions, resourceService, loggerFactory)
1315
{
1416
}
1517
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using JsonApiDotNetCore.Configuration;
22
using JsonApiDotNetCore.Controllers;
3-
using JsonApiDotNetCore.Internal.Contracts;
43
using JsonApiDotNetCore.Services;
54
using JsonApiDotNetCoreExample.Models;
65
using Microsoft.Extensions.Logging;
@@ -11,10 +10,9 @@ public class PeopleController : JsonApiController<Person>
1110
{
1211
public PeopleController(
1312
IJsonApiOptions jsonApiOptions,
14-
IResourceGraph resourceGraph,
1513
IResourceService<Person> resourceService,
1614
ILoggerFactory loggerFactory)
17-
: base(jsonApiOptions, resourceGraph, resourceService, loggerFactory)
15+
: base(jsonApiOptions, resourceService, loggerFactory)
1816
{ }
1917
}
2018
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using JsonApiDotNetCore.Configuration;
22
using JsonApiDotNetCore.Controllers;
3-
using JsonApiDotNetCore.Internal.Contracts;
43
using JsonApiDotNetCore.Services;
54
using JsonApiDotNetCoreExample.Models;
65
using Microsoft.Extensions.Logging;
@@ -11,10 +10,9 @@ public class PersonRolesController : JsonApiController<PersonRole>
1110
{
1211
public PersonRolesController(
1312
IJsonApiOptions jsonApiOptions,
14-
IResourceGraph resourceGraph,
1513
IResourceService<PersonRole> resourceService,
1614
ILoggerFactory loggerFactory)
17-
: base(jsonApiOptions, resourceGraph, resourceService, loggerFactory)
15+
: base(jsonApiOptions, resourceService, loggerFactory)
1816
{ }
1917
}
2018
}

src/Examples/JsonApiDotNetCoreExample/Controllers/TodoCollectionsController.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ public class TodoCollectionsController : JsonApiController<TodoItemCollection, G
1919

2020
public TodoCollectionsController(
2121
IJsonApiOptions jsonApiOptions,
22-
IResourceGraph resourceGraph,
2322
IDbContextResolver contextResolver,
2423
IResourceService<TodoItemCollection, Guid> resourceService,
2524
ILoggerFactory loggerFactory)
26-
: base(jsonApiOptions, resourceGraph, resourceService, loggerFactory)
25+
: base(jsonApiOptions, resourceService, loggerFactory)
2726
{
2827
_dbResolver = contextResolver;
2928
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using JsonApiDotNetCore.Configuration;
22
using JsonApiDotNetCore.Controllers;
3-
using JsonApiDotNetCore.Internal.Contracts;
43
using JsonApiDotNetCore.Services;
54
using JsonApiDotNetCoreExample.Models;
65
using Microsoft.Extensions.Logging;
@@ -10,11 +9,10 @@ namespace JsonApiDotNetCoreExample.Controllers
109
public class TodoItemsController : JsonApiController<TodoItem>
1110
{
1211
public TodoItemsController(
13-
IJsonApiOptions jsonApiOPtions,
14-
IResourceGraph resourceGraph,
12+
IJsonApiOptions jsonApiOptions,
1513
IResourceService<TodoItem> resourceService,
1614
ILoggerFactory loggerFactory)
17-
: base(jsonApiOPtions, resourceGraph, resourceService, loggerFactory)
15+
: base(jsonApiOptions, resourceService, loggerFactory)
1816
{ }
1917
}
2018
}

src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsCustomController.cs

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using System.Threading.Tasks;
3+
using JsonApiDotNetCore.Configuration;
34
using JsonApiDotNetCore.Controllers;
45
using JsonApiDotNetCore.Models;
56
using JsonApiDotNetCore.Services;
@@ -13,26 +14,30 @@ namespace JsonApiDotNetCoreExample.Controllers
1314
public class TodoItemsCustomController : CustomJsonApiController<TodoItem>
1415
{
1516
public TodoItemsCustomController(
17+
IJsonApiOptions options,
1618
IResourceService<TodoItem> resourceService,
1719
ILoggerFactory loggerFactory)
18-
: base(resourceService, loggerFactory)
20+
: base(options, resourceService, loggerFactory)
1921
{ }
2022
}
2123

2224
public class CustomJsonApiController<T>
2325
: CustomJsonApiController<T, int> where T : class, IIdentifiable<int>
2426
{
2527
public CustomJsonApiController(
28+
IJsonApiOptions options,
2629
IResourceService<T, int> resourceService,
2730
ILoggerFactory loggerFactory)
28-
: base(resourceService, loggerFactory)
29-
{ }
31+
: base(options, resourceService, loggerFactory)
32+
{
33+
}
3034
}
3135

3236
public class CustomJsonApiController<T, TId>
3337
: ControllerBase where T : class, IIdentifiable<TId>
3438
{
3539
private readonly ILogger _logger;
40+
private readonly IJsonApiOptions _options;
3641
private readonly IResourceService<T, TId> _resourceService;
3742

3843
protected IActionResult Forbidden()
@@ -41,11 +46,13 @@ protected IActionResult Forbidden()
4146
}
4247

4348
public CustomJsonApiController(
49+
IJsonApiOptions options,
4450
IResourceService<T, TId> resourceService,
4551
ILoggerFactory loggerFactory)
4652
{
53+
_options = options;
4754
_resourceService = resourceService;
48-
_logger = loggerFactory.CreateLogger<JsonApiDotNetCore.Controllers.JsonApiController<T, TId>>();
55+
_logger = loggerFactory.CreateLogger<JsonApiController<T, TId>>();
4956
}
5057

5158
public CustomJsonApiController(
@@ -95,8 +102,8 @@ public virtual async Task<IActionResult> PostAsync([FromBody] T entity)
95102
if (entity == null)
96103
return UnprocessableEntity();
97104

98-
//if (!_jsonApiContext.Options.AllowClientGeneratedIds && !string.IsNullOrEmpty(entity.StringId))
99-
// return Forbidden();
105+
if (_options.AllowClientGeneratedIds && !string.IsNullOrEmpty(entity.StringId))
106+
return Forbidden();
100107

101108
entity = await _resourceService.CreateAsync(entity);
102109

src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsTestController.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using JsonApiDotNetCore.Configuration;
22
using JsonApiDotNetCore.Controllers;
3-
using JsonApiDotNetCore.Internal.Contracts;
43
using JsonApiDotNetCore.Models;
54
using JsonApiDotNetCore.Services;
65
using JsonApiDotNetCoreExample.Models;
@@ -14,10 +13,9 @@ public abstract class AbstractTodoItemsController<T>
1413
{
1514
protected AbstractTodoItemsController(
1615
IJsonApiOptions jsonApiOptions,
17-
IResourceGraph resourceGraph,
1816
IResourceService<T, int> service,
1917
ILoggerFactory loggerFactory)
20-
: base(jsonApiOptions, resourceGraph, service, loggerFactory)
18+
: base(jsonApiOptions, service, loggerFactory)
2119
{ }
2220
}
2321

@@ -26,10 +24,9 @@ public class TodoItemsTestController : AbstractTodoItemsController<TodoItem>
2624
{
2725
public TodoItemsTestController(
2826
IJsonApiOptions jsonApiOptions,
29-
IResourceGraph resourceGraph,
3027
IResourceService<TodoItem> service,
3128
ILoggerFactory loggerFactory)
32-
: base(jsonApiOptions, resourceGraph, service, loggerFactory)
29+
: base(jsonApiOptions, service, loggerFactory)
3330
{ }
3431
}
3532
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using JsonApiDotNetCore.Configuration;
22
using JsonApiDotNetCore.Controllers;
3-
using JsonApiDotNetCore.Internal.Contracts;
43
using JsonApiDotNetCore.Services;
54
using JsonApiDotNetCoreExample.Models;
65
using Microsoft.Extensions.Logging;
@@ -11,10 +10,9 @@ public class UsersController : JsonApiController<User>
1110
{
1211
public UsersController(
1312
IJsonApiOptions jsonApiOptions,
14-
IResourceGraph resourceGraph,
1513
IResourceService<User> resourceService,
1614
ILoggerFactory loggerFactory)
17-
: base(jsonApiOptions, resourceGraph, resourceService, loggerFactory)
15+
: base(jsonApiOptions, resourceService, loggerFactory)
1816
{ }
1917
}
2018
}

src/Examples/JsonApiDotNetCoreExample/Resources/ArticleResource.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace JsonApiDotNetCoreExample.Resources
1111
{
1212
public class ArticleResource : ResourceDefinition<Article>
1313
{
14-
public ArticleResource(IResourceGraph graph) : base(graph) { }
14+
public ArticleResource(IResourceGraph resourceGraph) : base(resourceGraph) { }
1515

1616
public override IEnumerable<Article> OnReturn(HashSet<Article> entities, ResourcePipeline pipeline)
1717
{

src/Examples/JsonApiDotNetCoreExample/Resources/LockableResource.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace JsonApiDotNetCoreExample.Resources
1111
{
1212
public abstract class LockableResource<T> : ResourceDefinition<T> where T : class, IIsLockable, IIdentifiable
1313
{
14-
protected LockableResource(IResourceGraph graph) : base(graph) { }
14+
protected LockableResource(IResourceGraph resourceGraph) : base(resourceGraph) { }
1515

1616
protected void DisallowLocked(IEnumerable<T> entities)
1717
{

src/Examples/JsonApiDotNetCoreExample/Resources/PassportResource.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace JsonApiDotNetCoreExample.Resources
1111
{
1212
public class PassportResource : ResourceDefinition<Passport>
1313
{
14-
public PassportResource(IResourceGraph graph) : base(graph)
14+
public PassportResource(IResourceGraph resourceGraph) : base(resourceGraph)
1515
{
1616
}
1717

src/Examples/JsonApiDotNetCoreExample/Resources/PersonResource.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace JsonApiDotNetCoreExample.Resources
99
{
1010
public class PersonResource : LockableResource<Person>, IHasMeta
1111
{
12-
public PersonResource(IResourceGraph graph) : base(graph) { }
12+
public PersonResource(IResourceGraph resourceGraph) : base(resourceGraph) { }
1313

1414
public override IEnumerable<Person> BeforeUpdate(IDiffableEntityHashSet<Person> entities, ResourcePipeline pipeline)
1515
{

src/Examples/JsonApiDotNetCoreExample/Resources/TagResource.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace JsonApiDotNetCoreExample.Resources
1010
{
1111
public class TagResource : ResourceDefinition<Tag>
1212
{
13-
public TagResource(IResourceGraph graph) : base(graph) { }
13+
public TagResource(IResourceGraph resourceGraph) : base(resourceGraph) { }
1414

1515
public override IEnumerable<Tag> BeforeCreate(IEntityHashSet<Tag> affected, ResourcePipeline pipeline)
1616
{

src/Examples/JsonApiDotNetCoreExample/Resources/TodoResource.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace JsonApiDotNetCoreExample.Resources
1010
{
1111
public class TodoResource : LockableResource<TodoItem>
1212
{
13-
public TodoResource(IResourceGraph graph) : base(graph) { }
13+
public TodoResource(IResourceGraph resourceGraph) : base(resourceGraph) { }
1414

1515
public override void BeforeRead(ResourcePipeline pipeline, bool isIncluded = false, string stringId = null)
1616
{

src/Examples/JsonApiDotNetCoreExample/Resources/UserResource.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace JsonApiDotNetCoreExample.Resources
99
{
1010
public class UserResource : ResourceDefinition<User>
1111
{
12-
public UserResource(IResourceGraph graph, IFieldsExplorer fieldExplorer) : base(fieldExplorer, graph)
12+
public UserResource(IResourceGraph resourceGraph) : base(resourceGraph)
1313
{
1414
HideFields(u => u.Password);
1515
}

src/Examples/JsonApiDotNetCoreExample/Services/CustomArticleService.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public CustomArticleService(ISortService sortService,
2020
IIncludeService includeService,
2121
ISparseFieldsService sparseFieldsService,
2222
IPageService pageService,
23-
IResourceGraph resourceGraph,
23+
IContextEntityProvider provider,
2424
IResourceHookExecutor hookExecutor = null,
2525
ILoggerFactory loggerFactory = null)
2626
: base(sortService, filterService, repository, options, includeService, sparseFieldsService,
27-
pageService, resourceGraph, hookExecutor, loggerFactory)
27+
pageService, provider, hookExecutor, loggerFactory)
2828
{
2929
}
3030

src/Examples/JsonApiDotNetCoreExample/Startup.cs

+10-8
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ public virtual IServiceProvider ConfigureServices(IServiceCollection services)
3232
services
3333
.AddSingleton<ILoggerFactory>(loggerFactory)
3434
.AddDbContext<AppDbContext>(options => options.UseNpgsql(GetDbConnectionString()), ServiceLifetime.Transient)
35-
.AddJsonApi(options => {
36-
options.Namespace = "api/v1";
37-
options.DefaultPageSize = 5;
38-
options.IncludeTotalRecordCount = true;
39-
options.EnableResourceHooks = true;
40-
options.LoaDatabaseValues = true;
41-
},
42-
discovery => discovery.AddCurrentAssembly());
35+
.AddJsonApi(
36+
options =>
37+
{
38+
options.Namespace = "api/v1";
39+
options.DefaultPageSize = 5;
40+
options.IncludeTotalRecordCount = true;
41+
options.EnableResourceHooks = true;
42+
options.LoaDatabaseValues = true;
43+
},
44+
discovery => discovery.AddCurrentAssembly());
4345

4446
return services.BuildServiceProvider();
4547
}

0 commit comments

Comments
 (0)