Skip to content

Commit eec96a7

Browse files
author
Bart Koelman
committed
Bugfix: relationship links were rendered for ToMany relationships, even when explicitly turned off in global options (and not configured on the relationship itself).
1 parent 7255c9e commit eec96a7

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

src/JsonApiDotNetCore/Resources/Annotations/HasManyAttribute.cs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,17 @@ namespace JsonApiDotNetCore.Resources.Annotations
55
/// <summary>
66
/// Used to expose a property on a resource class as a JSON:API to-many relationship (https://jsonapi.org/format/#document-resource-object-relationships).
77
/// </summary>
8+
/// <example>
9+
/// <code><![CDATA[
10+
/// public class Author : Identifiable
11+
/// {
12+
/// [HasMany(PublicName = "articles")]
13+
/// public List<Article> Articles { get; set; }
14+
/// }
15+
/// ]]></code>
16+
/// </example>
817
[AttributeUsage(AttributeTargets.Property)]
918
public class HasManyAttribute : RelationshipAttribute
1019
{
11-
/// <summary>
12-
/// Creates a HasMany relational link to another resource.
13-
/// </summary>
14-
/// <example>
15-
/// <code><![CDATA[
16-
/// public class Author : Identifiable
17-
/// {
18-
/// [HasMany(PublicName = "articles")]
19-
/// public List<Article> Articles { get; set; }
20-
/// }
21-
/// ]]></code>
22-
/// </example>
23-
public HasManyAttribute()
24-
{
25-
Links = LinkTypes.All;
26-
}
2720
}
2821
}

src/JsonApiDotNetCore/Resources/Annotations/HasOneAttribute.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,5 @@ namespace JsonApiDotNetCore.Resources.Annotations
88
[AttributeUsage(AttributeTargets.Property)]
99
public sealed class HasOneAttribute : RelationshipAttribute
1010
{
11-
public HasOneAttribute()
12-
{
13-
Links = LinkTypes.NotConfigured;
14-
}
1511
}
1612
}

src/JsonApiDotNetCore/Resources/Annotations/RelationshipAttribute.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace JsonApiDotNetCore.Resources.Annotations
1010
/// </summary>
1111
public abstract class RelationshipAttribute : ResourceFieldAttribute
1212
{
13-
private LinkTypes _links;
13+
private LinkTypes _links = LinkTypes.NotConfigured;
1414

1515
/// <summary>
1616
/// The property name of the EF Core inverse navigation, which may or may not exist.
@@ -62,8 +62,7 @@ public abstract class RelationshipAttribute : ResourceFieldAttribute
6262
/// When not explicitly assigned, the default value depends on the relationship type (see remarks).
6363
/// </summary>
6464
/// <remarks>
65-
/// This defaults to <see cref="LinkTypes.All"/> for <see cref="HasManyAttribute"/> and <see cref="HasManyThroughAttribute"/> relationships.
66-
/// This defaults to <see cref="LinkTypes.NotConfigured"/> for <see cref="HasOneAttribute"/> relationships, which means that
65+
/// This defaults to <see cref="LinkTypes.NotConfigured"/>, which means that
6766
/// the configuration in <see cref="IJsonApiOptions"/> or <see cref="ResourceContext"/> is used.
6867
/// </remarks>
6968
public LinkTypes Links

0 commit comments

Comments
 (0)