Skip to content

Commit 11a3ef7

Browse files
MilosMilos
Milos
authored and
Milos
committed
Option renamed to DefaultRelationshipLinks and changed to Link type
1 parent 448aecf commit 11a3ef7

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Diff for: src/JsonApiDotNetCore/Builders/DocumentBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private RelationshipData GetRelationshipData(RelationshipAttribute attr, Context
168168

169169
var relationshipData = new RelationshipData();
170170

171-
if (!_jsonApiContext.Options.DisableSelfAndRelatedLinks && attr.DocumentLinks.HasFlag(Link.None) == false)
171+
if (_jsonApiContext.Options.DefaultRelationshipLinks.HasFlag(Link.None) == false && attr.DocumentLinks.HasFlag(Link.None) == false)
172172
{
173173
relationshipData.Links = new Links();
174174
if (attr.DocumentLinks.HasFlag(Link.Self))

Diff for: src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs

+13-3
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,24 @@ public class JsonApiOptions
103103
public bool RelativeLinks { get; set; }
104104

105105
/// <summary>
106-
/// Whether or not to include self and related links
106+
/// Which links to include in relationships. Defaults to <see cref="Link.All"/>.
107107
/// </summary>
108108
/// <example>
109109
/// <code>
110-
/// options.DisableSelfAndRelatedLinks = true;
110+
/// options.DefaultRelationshipLinks = Link.None;
111+
/// </code>
112+
/// <code>
113+
/// {
114+
/// "type": "articles",
115+
/// "id": "4309",
116+
/// "relationships": {
117+
/// "author": {}
118+
/// }
119+
/// }
120+
/// }
111121
/// </code>
112122
/// </example>
113-
public bool DisableSelfAndRelatedLinks { get; set; }
123+
public Link DefaultRelationshipLinks { get; set; } = Link.All;
114124

115125
/// <summary>
116126
/// Whether or not to allow all custom query parameters.

Diff for: test/UnitTests/Builders/DocumentBuilder_Tests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void Related_Links_Can_Be_Disabled_Globally()
130130
_pageManager.TotalRecords = 1;
131131
_pageManager.CurrentPage = 1;
132132

133-
_options.DisableSelfAndRelatedLinks = true;
133+
_options.DefaultRelationshipLinks = Link.None;
134134

135135
_jsonApiContextMock
136136
.Setup(m => m.ResourceGraph)

0 commit comments

Comments
 (0)