Skip to content

Feat/#171 #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ public class JsonApiOptions
public bool AllowClientGeneratedIds { get; set; }
public IContextGraph ContextGraph { get; set; }
public bool RelativeLinks { get; set; }

/// <summary>
/// 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.
/// </summary>
public bool AllowCustomQueryParameters { get; set; }
public IContractResolver JsonContractResolver { get; set; } = new DasherizedResolver();
internal IContextGraphBuilder ContextGraphBuilder { get; } = new ContextGraphBuilder();

Expand Down
7 changes: 4 additions & 3 deletions src/JsonApiDotNetCore/Internal/Query/QuerySet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand Down Expand Up @@ -101,9 +102,9 @@ private List<FilterQuery> 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));

Expand Down
2 changes: 1 addition & 1 deletion src/JsonApiDotNetCore/JsonApiDotNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>2.1.5</VersionPrefix>
<VersionPrefix>2.1.6</VersionPrefix>
<TargetFrameworks>netstandard1.6</TargetFrameworks>
<AssemblyName>JsonApiDotNetCore</AssemblyName>
<PackageId>JsonApiDotNetCore</PackageId>
Expand Down
2 changes: 1 addition & 1 deletion src/JsonApiDotNetCore/Services/QueryAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public bool TryGetValue<T>(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;
}
}