Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.0" />
<PackageReference Include="Microsoft.OpenApi" Version="1.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="System.Memory" Version="4.5.0" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions src/Csg.ListQuery.AspNetCore/PropertyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;

namespace Csg.ListQuery.AspNetCore
{
Expand All @@ -25,11 +25,11 @@ public static Dictionary<string, ListItemPropertyInfo> GetProperties(Type type,
.Select(prop =>
{
var propInfo = new ListItemPropertyInfo();
var jsonPropertyAttribute = prop.PropertyInfo.GetCustomAttributes(typeof(Newtonsoft.Json.JsonPropertyAttribute), false).FirstOrDefault();
var jsonPropertyAttribute = prop.PropertyInfo.GetCustomAttributes(typeof(JsonPropertyNameAttribute), false).FirstOrDefault();

propInfo.Property = prop.PropertyInfo;
propInfo.PropertyName = prop.Name;
propInfo.JsonName = ((Newtonsoft.Json.JsonPropertyAttribute)jsonPropertyAttribute)?.PropertyName ?? prop.Name;
propInfo.JsonName = ((JsonPropertyNameAttribute)jsonPropertyAttribute)?.Name ?? prop.Name;
propInfo.IsFilterable = prop.IsFilterable == true;
propInfo.IsSortable = prop.IsSortable == true;
propInfo.Description = prop.Description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Csg.ListQuery.Server.Abstractions\Csg.ListQuery.Server.Abstractions.csproj" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Csg.ListQuery.JsonApi.Abstractions/JsonApiListResponse.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using Csg.ListQuery.Server;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace Csg.ListQuery.JsonApi.Abstractions
{
public class JsonApiListResponse<TAttributes> : ListResponse<JsonApiRecord<TAttributes>>
{
[JsonProperty("data")]
[JsonPropertyName("data")]
public override IEnumerable<JsonApiRecord<TAttributes>> Data { get => base.Data; set => base.Data = value; }

[JsonProperty("links")]
[JsonPropertyName("links")]
public override ListResponseLinks Links { get => base.Links; set => base.Links = value; }

[JsonProperty("meta")]
[JsonPropertyName("meta")]
public override ListResponseMeta Meta { get => base.Meta; set => base.Meta = value; }
}
}
8 changes: 4 additions & 4 deletions src/Csg.ListQuery.JsonApi.Abstractions/JsonApiRecord.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace Csg.ListQuery.JsonApi.Abstractions
{
Expand All @@ -21,13 +21,13 @@ public JsonApiRecord(string type, string id, TAttributes attributes) : this()
this.Attributes = attributes;
}

[JsonProperty("type")]
[JsonPropertyName("type")]
public string Type { get; set; }

[JsonProperty("id")]
[JsonPropertyName("id")]
public string ID { get; set; }

[JsonProperty("attributes")]
[JsonPropertyName("attributes")]
public TAttributes Attributes { get; set; }
}
}