Skip to content

Commit f0e84ef

Browse files
committed
docs: add missing API documentation
1 parent 882cbfd commit f0e84ef

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

docs/api/index.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
# PLACEHOLDER
2-
TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*!
1+
# API
2+
3+
This section documents the package API and is generated from the XML source comments.
4+
5+
## Common APIs
6+
7+
- [`JsonApiOptions`](JsonApiDotNetCore.Configuration.JsonApiOptions.html)
8+
- [`IResourceGraph`](JsonApiDotNetCore.Internal.IResourceGraph.html)
9+
- [`ResourceDefinition<T>`](JsonApiDotNetCore.Models.ResourceDefinition-1.html)
10+
- [`IQueryAccessor`](JsonApiDotNetCore.Services.IQueryAccessor.html)

src/JsonApiDotNetCore/Builders/ContextGraphBuilder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ public class ResourceGraphBuilder : IResourceGraphBuilder
8181
private bool _usesDbContext;
8282
private IResourceNameFormatter _resourceNameFormatter = JsonApiOptions.ResourceNameFormatter;
8383

84+
/// <inheritdoc />
8485
public Link DocumentLinks { get; set; } = Link.All;
8586

87+
/// <inheritdoc />
8688
public IResourceGraph Build()
8789
{
8890
// this must be done at build so that call order doesn't matter

src/JsonApiDotNetCore/Builders/DocumentBuilder.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace JsonApiDotNetCore.Builders
1111
{
12+
/// <inheritdoc />
1213
public class DocumentBuilder : IDocumentBuilder
1314
{
1415
private readonly IJsonApiContext _jsonApiContext;
@@ -30,6 +31,7 @@ public DocumentBuilder(
3031
_scopedServiceProvider = scopedServiceProvider;
3132
}
3233

34+
/// <inheritdoc />
3335
public Document Build(IIdentifiable entity)
3436
{
3537
var contextEntity = _resourceGraph.GetContextEntity(entity.GetType());
@@ -49,6 +51,7 @@ public Document Build(IIdentifiable entity)
4951
return document;
5052
}
5153

54+
/// <inheritdoc />
5255
public Documents Build(IEnumerable<IIdentifiable> entities)
5356
{
5457
var entityType = entities.GetElementType();
@@ -110,6 +113,7 @@ private List<ResourceObject> AppendIncludedObject(List<ResourceObject> includedO
110113
public ResourceObject GetData(ContextEntity contextEntity, IIdentifiable entity)
111114
=> GetData(contextEntity, entity, resourceDefinition: null);
112115

116+
/// <inheritdoc />
113117
public ResourceObject GetData(ContextEntity contextEntity, IIdentifiable entity, IResourceDefinition resourceDefinition = null)
114118
{
115119
var data = new ResourceObject
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
11
namespace JsonApiDotNetCore.Builders
22
{
3+
/// <summary>
4+
/// Options used to configure how a model gets serialized into
5+
/// a json:api document.
6+
/// </summary>
37
public struct DocumentBuilderOptions
48
{
9+
/// <param name="omitNullValuedAttributes">
10+
/// Do not serialize attributes with null values.
11+
/// </param>
512
public DocumentBuilderOptions(bool omitNullValuedAttributes = false)
613
{
714
this.OmitNullValuedAttributes = omitNullValuedAttributes;
815
}
916

17+
/// <summary>
18+
/// Prevent attributes with null values from being included in the response.
19+
/// This type is mostly internal and if you want to enable this behavior, you
20+
/// should do so on the <see ref="JsonApiDotNetCore.Configuration.JsonApiOptions" />.
21+
/// </summary>
22+
/// <example>
23+
/// <code>
24+
/// options.NullAttributeResponseBehavior = new NullAttributeResponseBehavior(true);
25+
/// </code>
26+
/// </example>
1027
public bool OmitNullValuedAttributes { get; private set; }
1128
}
1229
}

src/JsonApiDotNetCore/Builders/IDocumentBuilder.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,31 @@ namespace JsonApiDotNetCore.Builders
77
{
88
public interface IDocumentBuilder
99
{
10+
/// <summary>
11+
/// Builds a json:api document from the provided resource instance.
12+
/// </summary>
13+
/// <param name="entity">The resource to convert.</param>
1014
Document Build(IIdentifiable entity);
15+
16+
/// <summary>
17+
/// Builds a json:api document from the provided resource instances.
18+
/// </summary>
19+
/// <param name="entities">The collection of resources to convert.</param>
1120
Documents Build(IEnumerable<IIdentifiable> entities);
1221

1322
[Obsolete("You should specify an IResourceDefinition implementation using the GetData/3 overload.")]
1423
ResourceObject GetData(ContextEntity contextEntity, IIdentifiable entity);
24+
25+
/// <summary>
26+
/// Create the resource object for the provided resource.
27+
/// </summary>
28+
/// <param name="contextEntity">The metadata for the resource.</param>
29+
/// <param name="entity">The resource instance.</param>
30+
/// <param name="resourceDefinition">
31+
/// The resource definition (optional). This can be used for filtering out attributes
32+
/// that should not be exposed to the client. For example, you might want to limit
33+
/// the exposed attributes based on the authenticated user's role.
34+
/// </param>
1535
ResourceObject GetData(ContextEntity contextEntity, IIdentifiable entity, IResourceDefinition resourceDefinition = null);
1636
}
1737
}

0 commit comments

Comments
 (0)