Table of Contents

Class ResourceFieldAttribute

Namespace
JsonApiDotNetCore.Resources.Annotations
Assembly
JsonApiDotNetCore.Annotations.dll

Used to expose a property on a resource class as a JSON:API field (attribute or relationship). See https://jsonapi.org/format/#document-resource-object-fields.

[PublicAPI]
public abstract class ResourceFieldAttribute : Attribute
Inheritance
ResourceFieldAttribute
Derived
Inherited Members

Properties

Property

The resource property that this attribute is declared on.

public PropertyInfo Property { get; }

Property Value

PropertyInfo

PublicName

The publicly exposed name of this JSON:API field. When not explicitly set, the configured naming convention is applied on the property name.

public string PublicName { get; set; }

Property Value

string

Type

The containing resource type in which this field is declared.

public ResourceType Type { get; }

Property Value

ResourceType

Methods

AssertIsIdentifiable(object?)

protected void AssertIsIdentifiable(object? resource)

Parameters

resource object

Equals(object?)

Returns a value that indicates whether this instance is equal to a specified object.

public override bool Equals(object? obj)

Parameters

obj object

An object to compare with this instance or null.

Returns

bool

true if obj and this instance are of the same type and have identical field values; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer hash code.

GetValue(object)

Gets the value of this field on the specified resource instance. Throws if the property is write-only or if the field does not belong to the specified resource instance.

public object? GetValue(object resource)

Parameters

resource object

Returns

object

SetValue(object, object?)

Sets the value of this field on the specified resource instance. Throws if the property is read-only or if the field does not belong to the specified resource instance.

public virtual void SetValue(object resource, object? newValue)

Parameters

resource object
newValue object

ToString()

Returns a string that represents the current object.

public override string? ToString()

Returns

string

A string that represents the current object.