Skip to content

Commit d1af7cc

Browse files
committed
chore: various minor fixes, PR self review
1 parent f78a188 commit d1af7cc

22 files changed

+76
-44
lines changed

src/Examples/JsonApiDotNetCoreExample/Controllers/Restricted/ReadOnlyController.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
namespace JsonApiDotNetCoreExample.Controllers.Restricted
55
{
6-
76
[Route("[controller]")]
87
[HttpReadOnly]
98
public class ReadOnlyController : ControllerBase

src/Examples/JsonApiDotNetCoreExample/Services/CustomArticleService.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,19 @@ namespace JsonApiDotNetCoreExample.Services
1616
{
1717
public class CustomArticleService : EntityResourceService<Article>
1818
{
19-
public CustomArticleService(ISortService sortService, IFilterService filterService, IEntityRepository<Article, int> repository, IJsonApiOptions options, ICurrentRequest currentRequest, IIncludeService includeService, ISparseFieldsService sparseFieldsService, IPageService pageManager, IResourceGraph resourceGraph, IResourceHookExecutor hookExecutor = null, ILoggerFactory loggerFactory = null) : base(sortService, filterService, repository, options, currentRequest, includeService, sparseFieldsService, pageManager, resourceGraph, hookExecutor, loggerFactory)
19+
public CustomArticleService(ISortService sortService,
20+
IFilterService filterService,
21+
IEntityRepository<Article, int> repository,
22+
IJsonApiOptions options,
23+
ICurrentRequest currentRequest,
24+
IIncludeService includeService,
25+
ISparseFieldsService sparseFieldsService,
26+
IPageService pageManager,
27+
IResourceGraph resourceGraph,
28+
IResourceHookExecutor hookExecutor = null,
29+
ILoggerFactory loggerFactory = null)
30+
: base(sortService, filterService, repository, options, currentRequest, includeService, sparseFieldsService,
31+
pageManager, resourceGraph, hookExecutor, loggerFactory)
2032
{
2133
}
2234

src/Examples/NoEntityFrameworkExample/Properties/launchSettings.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
}
99
},
1010
"profiles": {
11-
"IIS Express": {
12-
"commandName": "IISExpress",
13-
"launchBrowser": true,
14-
"environmentVariables": {
15-
"ASPNETCORE_ENVIRONMENT": "Development"
16-
}
17-
},
1811
"NoEntityFrameworkExample": {
1912
"commandName": "Project",
2013
"launchBrowser": true,
2114
"environmentVariables": {
2215
"ASPNETCORE_ENVIRONMENT": "Development"
2316
},
2417
"applicationUrl": "http://localhost:5000/"
18+
},
19+
"IIS Express": {
20+
"commandName": "IISExpress",
21+
"launchBrowser": true,
22+
"environmentVariables": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
}
2525
}
2626
}
2727
}

src/JsonApiDotNetCore/Controllers/DisableQueryAttribute.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@
33
namespace JsonApiDotNetCore.Controllers
44
{
55
public class DisableQueryAttribute : Attribute
6-
{
6+
{
7+
/// <summary>
8+
/// Disabled one of the native query parameters for a controller.
9+
/// </summary>
10+
/// <param name="queryParams"></param>
711
public DisableQueryAttribute(QueryParams queryParams)
812
{
913
QueryParams = queryParams.ToString("G").ToLower();
1014
}
1115

16+
/// <summary>
17+
/// It is allowed to use strings to indicate which query parameters
18+
/// should be disabled, because the user may have defined a custom
19+
/// query parameter that is not included in the <see cref="QueryParams"/> enum.
20+
/// </summary>
21+
/// <param name="customQueryParams"></param>
1222
public DisableQueryAttribute(string customQueryParams)
1323
{
1424
QueryParams = customQueryParams.ToLower();
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
namespace JsonApiDotNetCore.Internal.Query
22
{
33
public static class QueryConstants {
4-
public const string FILTER = "filter";
5-
public const string SORT = "sort";
6-
public const string INCLUDE = "include";
7-
public const string PAGE = "page";
8-
public const string FIELDS = "fields";
94
public const char OPEN_BRACKET = '[';
105
public const char CLOSE_BRACKET = ']';
116
public const char COMMA = ',';
127
public const char COLON = ':';
138
public const string COLON_STR = ":";
149
public const char DOT = '.';
15-
1610
}
1711
}

src/JsonApiDotNetCore/JsonApiDotNetCore.csproj

-13
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,4 @@
4444
<ItemGroup Condition="'$(GenerateDocumentation)' == 'true'">
4545
<PackageReference Include="docfx.console" Version="2.33.0" />
4646
</ItemGroup>
47-
<ItemGroup>
48-
<Folder Include="Models\JsonApiDocuments\" />
49-
<Folder Include="QueryParameterServices\" />
50-
<Folder Include="Internal\Exceptions\" />
51-
<Folder Include="Models\Annotation\" />
52-
<Folder Include="Serialization\Common\" />
53-
<Folder Include="Serialization\Client\" />
54-
<Folder Include="Serialization\Server\" />
55-
<Folder Include="Serialization\Server\Builders\" />
56-
<Folder Include="QueryParameterServices\Contracts\" />
57-
<Folder Include="QueryParameterServices\Common\" />
58-
<Folder Include="Serialization\Server\Contracts\" />
59-
</ItemGroup>
6047
</Project>

src/JsonApiDotNetCore/QueryParameterServices/Common/IQueryParameterParser.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace JsonApiDotNetCore.Services
77
/// Responsible for populating the various service implementations of
88
/// <see cref="IQueryParameterService"/>.
99
/// </summary>
10-
public interface IQueryParameterParser
10+
public interface IQueryParameterDiscovery
1111
{
1212
void Parse(IQueryCollection query, DisableQueryAttribute disabledQuery = null);
1313
}

src/JsonApiDotNetCore/QueryParameterServices/Common/IQueryParameterService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public interface IQueryParameterService
1111
/// <summary>
1212
/// Parses the value of the query parameter. Invoked in the middleware.
1313
/// </summary>
14-
/// <param name="queryParameter">the value of the query parameter as parsed from the url</param>
14+
/// <param name="queryParameter">the value of the query parameter as retrieved from the url</param>
1515
void Parse(KeyValuePair<string, StringValues> queryParameter);
1616
/// <summary>
1717
/// The name of the query parameter as matched in the URL query string.

src/JsonApiDotNetCore/QueryParameterServices/Common/QueryParameterService.cs

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ protected AttrAttribute GetAttribute(string target, RelationshipAttribute relati
6464
return attribute;
6565
}
6666

67-
6867
/// <summary>
6968
/// Helper method for parsing query parameters into relationships attributes
7069
/// </summary>

src/JsonApiDotNetCore/QueryParameterServices/Contracts/IFilterService.cs

+6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33

44
namespace JsonApiDotNetCore.Query
55
{
6+
/// <summary>
7+
/// Query parameter service responsible for url queries of the form ?filter[X]=Y
8+
/// </summary>
69
public interface IFilterService : IQueryParameterService
710
{
11+
/// <summary>
12+
/// Gets the parsed filter queries
13+
/// </summary>
814
List<FilterQueryContext> Get();
915
}
1016
}

src/JsonApiDotNetCore/QueryParameterServices/Contracts/IIncludeService.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
namespace JsonApiDotNetCore.Query
55
{
66
/// <summary>
7-
/// Query service to access the inclusion chains.
7+
/// Query parameter service responsible for url queries of the form ?include=X.Y.Z,U.V.W
88
/// </summary>
99
public interface IIncludeService : IQueryParameterService
1010
{
1111
/// <summary>
12-
/// Gets the list of included relationships chains for the current request.
12+
/// Gets the parsed relationship inclusion chains.
1313
/// </summary>
1414
List<List<RelationshipAttribute>> Get();
1515
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
namespace JsonApiDotNetCore.Query
22
{
3+
/// <summary>
4+
/// Query parameter service responsible for url queries of the form ?omitDefault=true
5+
/// </summary>
36
public interface IOmitDefaultService : IQueryParameterService
47
{
8+
/// <summary>
9+
/// Gets the parsed config
10+
/// </summary>
511
bool Config { get; }
612
}
713
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
namespace JsonApiDotNetCore.Query
22
{
3+
/// <summary>
4+
/// Query parameter service responsible for url queries of the form ?omitNull=true
5+
/// </summary>
36
public interface IOmitNullService : IQueryParameterService
47
{
8+
/// <summary>
9+
/// Gets the parsed config
10+
/// </summary>
511
bool Config { get; }
612
}
713
}

src/JsonApiDotNetCore/QueryParameterServices/Contracts/IPageService.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace JsonApiDotNetCore.Query
22
{
33
/// <summary>
4-
/// The former page manager. Needs some work.
4+
/// Query parameter service responsible for url queries of the form ?page[size]=X&page[number]=Y
55
/// </summary>
66
public interface IPageService : IQueryParameterService
77
{
@@ -28,7 +28,7 @@ public interface IPageService : IQueryParameterService
2828
int TotalPages { get; }
2929

3030
/// <summary>
31-
/// Pagination is enabled
31+
/// Checks if pagination is enabled
3232
/// </summary>
3333
bool ShouldPaginate();
3434
}

src/JsonApiDotNetCore/QueryParameterServices/Contracts/ISortService.cs

+6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33

44
namespace JsonApiDotNetCore.Query
55
{
6+
/// <summary>
7+
/// Query parameter service responsible for url queries of the form ?sort=-X
8+
/// </summary>
69
public interface ISortService : IQueryParameterService
710
{
11+
/// <summary>
12+
/// Gets the parsed sort queries
13+
/// </summary>
814
List<SortQueryContext> Get();
915
}
1016
}

src/JsonApiDotNetCore/QueryParameterServices/Contracts/ISparseFieldsService.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
namespace JsonApiDotNetCore.Query
55
{
66
/// <summary>
7-
/// Query service to access sparse field selection.
7+
/// Query parameter service responsible for url queries of the form ?fields[X]=U,V,W
88
/// </summary>
99
public interface ISparseFieldsService : IQueryParameterService
1010
{
1111
/// <summary>
12-
/// Gets the list of targeted fields. In a relationship is supplied,
12+
/// Gets the list of targeted fields. If a relationship is supplied,
1313
/// gets the list of targeted fields for that relationship.
1414
/// </summary>
1515
/// <param name="relationship"></param>

src/JsonApiDotNetCore/QueryParameterServices/FilterService.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
namespace JsonApiDotNetCore.Query
1212
{
13+
/// <inheritdoc/>
1314
public class FilterService : QueryParameterService, IFilterService
1415
{
15-
1616
private readonly List<FilterQueryContext> _filters;
1717
private IResourceDefinition _requestResourceDefinition;
1818

@@ -22,11 +22,13 @@ public FilterService(IResourceDefinitionProvider resourceDefinitionProvider, ICo
2222
_filters = new List<FilterQueryContext>();
2323
}
2424

25+
/// <inheritdoc/>
2526
public List<FilterQueryContext> Get()
2627
{
2728
return _filters;
2829
}
2930

31+
/// <inheritdoc/>
3032
public virtual void Parse(KeyValuePair<string, StringValues> queryParameter)
3133
{
3234
var queries = GetFilterQueries(queryParameter);

src/JsonApiDotNetCore/QueryParameterServices/IncludeService.cs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace JsonApiDotNetCore.Query
1111
{
12-
1312
public class IncludeService : QueryParameterService, IIncludeService
1413
{
1514
/// todo: use read-only lists.

src/JsonApiDotNetCore/QueryParameterServices/OmitDefaultService.cs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace JsonApiDotNetCore.Query
66
{
7+
/// <inheritdoc/>
78
public class OmitDefaultService : QueryParameterService, IOmitDefaultService
89
{
910
private readonly IJsonApiOptions _options;
@@ -14,8 +15,10 @@ public OmitDefaultService(IJsonApiOptions options)
1415
_options = options;
1516
}
1617

18+
/// <inheritdoc/>
1719
public bool Config { get; private set; }
1820

21+
/// <inheritdoc/>
1922
public virtual void Parse(KeyValuePair<string, StringValues> queryParameter)
2023
{
2124
if (!_options.DefaultAttributeResponseBehavior.AllowClientOverride)

src/JsonApiDotNetCore/QueryParameterServices/OmitNullService.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
using System;
21
using System.Collections.Generic;
32
using JsonApiDotNetCore.Configuration;
4-
using JsonApiDotNetCore.Internal;
53
using Microsoft.Extensions.Primitives;
64

75
namespace JsonApiDotNetCore.Query
86
{
7+
/// <inheritdoc/>
98
public class OmitNullService : QueryParameterService, IOmitNullService
109
{
1110
private readonly IJsonApiOptions _options;
@@ -16,8 +15,10 @@ public OmitNullService(IJsonApiOptions options)
1615
_options = options;
1716
}
1817

18+
/// <inheritdoc/>
1919
public bool Config { get; private set; }
2020

21+
/// <inheritdoc/>
2122
public virtual void Parse(KeyValuePair<string, StringValues> queryParameter)
2223
{
2324
if (!_options.NullAttributeResponseBehavior.AllowClientOverride)

src/JsonApiDotNetCore/QueryParameterServices/PageService.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace JsonApiDotNetCore.Query
99
{
10+
/// <inheritdoc/>
1011
public class PageService : QueryParameterService, IPageService
1112
{
1213
private IJsonApiOptions _options;
@@ -28,7 +29,8 @@ public PageService(IJsonApiOptions options)
2829
/// <inheritdoc/>
2930
public int TotalPages => (TotalRecords == null) ? -1 : (int)Math.Ceiling(decimal.Divide(TotalRecords.Value, PageSize));
3031

31-
public override void Parse(KeyValuePair<string, StringValues> queryParameter)
32+
/// <inheritdoc/>
33+
public virtual void Parse(KeyValuePair<string, StringValues> queryParameter)
3234
{
3335
// expected input = page[size]=10
3436
// page[number]=1
@@ -53,7 +55,6 @@ public override void Parse(KeyValuePair<string, StringValues> queryParameter)
5355
}
5456
}
5557

56-
5758
/// <inheritdoc/>
5859
public bool ShouldPaginate()
5960
{

src/JsonApiDotNetCore/QueryParameterServices/SortService.cs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace JsonApiDotNetCore.Query
1010
{
11+
/// <inheritdoc/>
1112
public class SortService : QueryParameterService, ISortService
1213
{
1314
const char DESCENDING_SORT_OPERATOR = '-';

0 commit comments

Comments
 (0)