diff --git a/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs b/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs index 2e24d52d53..3d169998a3 100644 --- a/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs +++ b/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs @@ -15,6 +15,15 @@ public class JsonApiOptions public bool AllowClientGeneratedIds { get; set; } public IContextGraph ContextGraph { get; set; } public bool RelativeLinks { get; set; } + + /// + /// This flag is experimental and could be perceived as a violation + /// of the v1 spec. However, we have decided that this is a real + /// requirement for users of this library and a gap in the specification. + /// It will likely be removed when the spec is updated to support this + /// requirement. + /// + public bool AllowCustomQueryParameters { get; set; } public IContractResolver JsonContractResolver { get; set; } = new DasherizedResolver(); internal IContextGraphBuilder ContextGraphBuilder { get; } = new ContextGraphBuilder(); diff --git a/src/JsonApiDotNetCore/Internal/Query/QuerySet.cs b/src/JsonApiDotNetCore/Internal/Query/QuerySet.cs index acf448d69d..628e6187a3 100644 --- a/src/JsonApiDotNetCore/Internal/Query/QuerySet.cs +++ b/src/JsonApiDotNetCore/Internal/Query/QuerySet.cs @@ -68,7 +68,8 @@ private void BuildQuerySet(IQueryCollection query) continue; } - throw new JsonApiException(400, $"{pair} is not a valid query."); + if (_jsonApiContext.Options.AllowCustomQueryParameters == false) + throw new JsonApiException(400, $"{pair} is not a valid query."); } } @@ -101,9 +102,9 @@ private List ParseFilterQuery(string key, string value) return (string.Empty, value); // remove prefix from value - if(Enum.TryParse(operation[0], out FilterOperations op) == false) + if (Enum.TryParse(operation[0], out FilterOperations op) == false) return (string.Empty, value); - + var prefix = operation[0]; value = string.Join(":", operation.Skip(1)); diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj index baad778f59..9177566e00 100755 --- a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj +++ b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj @@ -1,6 +1,6 @@  - 2.1.5 + 2.1.6 netstandard1.6 JsonApiDotNetCore JsonApiDotNetCore diff --git a/src/JsonApiDotNetCore/Services/QueryAccessor.cs b/src/JsonApiDotNetCore/Services/QueryAccessor.cs index 0862e3fd3e..09942d4031 100644 --- a/src/JsonApiDotNetCore/Services/QueryAccessor.cs +++ b/src/JsonApiDotNetCore/Services/QueryAccessor.cs @@ -63,7 +63,7 @@ public bool TryGetValue(string key, out T value) private string GetFilterValue(string key) => _jsonApiContext.QuerySet .Filters - .FirstOrDefault(f => f.Key == key) + .FirstOrDefault(f => string.Equals(f.Key, key, StringComparison.OrdinalIgnoreCase)) ?.Value; } } \ No newline at end of file