Skip to content

Commit 87531cb

Browse files
committed
reintroduce a RouteBuilder
1 parent eb893a3 commit 87531cb

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

JsonApiDotNetCore/Configuration/JsonApiModelConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Reflection;
55
using AutoMapper;
6+
using JsonApiDotNetCore.JsonApi;
67
using JsonApiDotNetCore.Routing;
78
using Microsoft.AspNetCore.Http;
89
using Microsoft.EntityFrameworkCore;

JsonApiDotNetCore/JsonApi/DocumentBuilder.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,23 @@ namespace JsonApiDotNetCore.JsonApi
44
{
55
public static class DocumentBuilder
66
{
7-
public static Dictionary<string, string> BuildSelfLink(string protocol, string host, string nameSpace, string modelRouteName, string resourceId)
7+
public static Dictionary<string, string> BuildSelfLink(string protocol, string host, string nameSpace, string resourceCollectionName, string resourceId)
88
{
99
var id = resourceId != null ? $"/{resourceId}" : string.Empty;
1010
return new Dictionary<string, string>
1111
{
1212
{
13-
"self", $"{protocol}://{host}/{nameSpace}/{modelRouteName}{id}"
13+
"self", $"{protocol}://{host}/{nameSpace}/{resourceCollectionName}{id}"
1414
}
1515
};
1616
}
17-
public static Dictionary<string, string> BuildSelfLink(string nameSpace, string modelRouteName)
18-
{
19-
return new Dictionary<string, string>
20-
{
21-
{
22-
"self", $"/{nameSpace}/{modelRouteName}"
23-
}
24-
};
25-
}
26-
public static Dictionary<string, string> BuildRelationshipLinks(string protocol, string host, string nameSpace, string modelRouteName, string resourceId, string relationshipName)
17+
18+
public static Dictionary<string, string> BuildRelationshipLinks(string protocol, string host, string nameSpace, string resourceCollectionName, string resourceId, string relationshipName)
2719
{
2820
return new Dictionary<string, string>
2921
{
30-
{"self", $"{protocol}://{host}/{nameSpace}/{modelRouteName}/{resourceId}/relationships/{relationshipName}"},
31-
{"related", $"{protocol}://{host}/{nameSpace}/{modelRouteName}/{resourceId}/{relationshipName}"}
22+
{"self", $"{protocol}://{host}/{nameSpace}/{resourceCollectionName}/{resourceId}/relationships/{relationshipName}"},
23+
{"related", $"{protocol}://{host}/{nameSpace}/{resourceCollectionName}/{resourceId}/{relationshipName}"}
3224
};
3325
}
3426
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace JsonApiDotNetCore.Routing
2+
{
3+
public static class RouteBuilder
4+
{
5+
public static string BuildRoute(string nameSpace, string resourceCollectionName)
6+
{
7+
return $"/{nameSpace}/{resourceCollectionName}";
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)