Skip to content

Commit 745eacc

Browse files
author
Bart Koelman
committed
Clarifications in doc-comments
1 parent 2802d23 commit 745eacc

File tree

3 files changed

+50
-19
lines changed

3 files changed

+50
-19
lines changed

src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ protected BaseJsonApiController(IJsonApiOptions options, IResourceGraph resource
8787
}
8888

8989
/// <summary>
90-
/// Gets a collection of top-level (non-nested) resources. Example: GET /articles HTTP/1.1
90+
/// Gets a collection of primary resources. Example: <code><![CDATA[
91+
/// GET /articles HTTP/1.1
92+
/// ]]></code>
9193
/// </summary>
9294
public virtual async Task<IActionResult> GetAsync(CancellationToken cancellationToken)
9395
{
@@ -104,7 +106,9 @@ public virtual async Task<IActionResult> GetAsync(CancellationToken cancellation
104106
}
105107

106108
/// <summary>
107-
/// Gets a single top-level (non-nested) resource by ID. Example: /articles/1
109+
/// Gets a single primary resource by ID. Example: <code><![CDATA[
110+
/// GET /articles/1 HTTP/1.1
111+
/// ]]></code>
108112
/// </summary>
109113
public virtual async Task<IActionResult> GetAsync(TId id, CancellationToken cancellationToken)
110114
{
@@ -124,7 +128,12 @@ public virtual async Task<IActionResult> GetAsync(TId id, CancellationToken canc
124128
}
125129

126130
/// <summary>
127-
/// Gets a single resource or multiple resources at a nested endpoint. Examples: GET /articles/1/author HTTP/1.1 GET /articles/1/revisions HTTP/1.1
131+
/// Gets a secondary resource or collection of secondary resources. Example: <code><![CDATA[
132+
/// GET /articles/1/author HTTP/1.1
133+
/// ]]></code> Example:
134+
/// <code><![CDATA[
135+
/// GET /articles/1/revisions HTTP/1.1
136+
/// ]]></code>
128137
/// </summary>
129138
public virtual async Task<IActionResult> GetSecondaryAsync(TId id, string relationshipName, CancellationToken cancellationToken)
130139
{
@@ -147,7 +156,13 @@ public virtual async Task<IActionResult> GetSecondaryAsync(TId id, string relati
147156
}
148157

149158
/// <summary>
150-
/// Gets a single resource relationship. Example: GET /articles/1/relationships/author HTTP/1.1 Example: GET /articles/1/relationships/revisions HTTP/1.1
159+
/// Gets a relationship value, which can be a <c>null</c>, a single object or a collection. Example:
160+
/// <code><![CDATA[
161+
/// GET /articles/1/relationships/author HTTP/1.1
162+
/// ]]></code> Example:
163+
/// <code><![CDATA[
164+
/// GET /articles/1/relationships/revisions HTTP/1.1
165+
/// ]]></code>
151166
/// </summary>
152167
public virtual async Task<IActionResult> GetRelationshipAsync(TId id, string relationshipName, CancellationToken cancellationToken)
153168
{
@@ -170,7 +185,9 @@ public virtual async Task<IActionResult> GetRelationshipAsync(TId id, string rel
170185
}
171186

172187
/// <summary>
173-
/// Creates a new resource with attributes, relationships or both. Example: POST /articles HTTP/1.1
188+
/// Creates a new resource with attributes, relationships or both. Example: <code><![CDATA[
189+
/// POST /articles HTTP/1.1
190+
/// ]]></code>
174191
/// </summary>
175192
public virtual async Task<IActionResult> PostAsync([FromBody] TResource resource, CancellationToken cancellationToken)
176193
{
@@ -206,7 +223,9 @@ public virtual async Task<IActionResult> PostAsync([FromBody] TResource resource
206223
}
207224

208225
/// <summary>
209-
/// Adds resources to a to-many relationship. Example: POST /articles/1/revisions HTTP/1.1
226+
/// Adds resources to a to-many relationship. Example: <code><![CDATA[
227+
/// POST /articles/1/revisions HTTP/1.1
228+
/// ]]></code>
210229
/// </summary>
211230
/// <param name="id">
212231
/// Identifies the left side of the relationship.
@@ -245,7 +264,9 @@ public virtual async Task<IActionResult> PostRelationshipAsync(TId id, string re
245264

246265
/// <summary>
247266
/// Updates the attributes and/or relationships of an existing resource. Only the values of sent attributes are replaced. And only the values of sent
248-
/// relationships are replaced. Example: PATCH /articles/1 HTTP/1.1
267+
/// relationships are replaced. Example: <code><![CDATA[
268+
/// PATCH /articles/1 HTTP/1.1
269+
/// ]]></code>
249270
/// </summary>
250271
public virtual async Task<IActionResult> PatchAsync(TId id, [FromBody] TResource resource, CancellationToken cancellationToken)
251272
{
@@ -268,12 +289,18 @@ public virtual async Task<IActionResult> PatchAsync(TId id, [FromBody] TResource
268289
}
269290

270291
TResource? updated = await _update.UpdateAsync(id, resource, cancellationToken);
292+
271293
return updated == null ? NoContent() : Ok(updated);
272294
}
273295

274296
/// <summary>
275-
/// Performs a complete replacement of a relationship on an existing resource. Example: PATCH /articles/1/relationships/author HTTP/1.1 Example: PATCH
276-
/// /articles/1/relationships/revisions HTTP/1.1
297+
/// Performs a complete replacement of a relationship on an existing resource. Example:
298+
/// <code><![CDATA[
299+
/// PATCH /articles/1/relationships/author HTTP/1.1
300+
/// ]]></code> Example:
301+
/// <code><![CDATA[
302+
/// PATCH /articles/1/relationships/revisions HTTP/1.1
303+
/// ]]></code>
277304
/// </summary>
278305
/// <param name="id">
279306
/// Identifies the left side of the relationship.
@@ -310,7 +337,9 @@ public virtual async Task<IActionResult> PatchRelationshipAsync(TId id, string r
310337
}
311338

312339
/// <summary>
313-
/// Deletes an existing resource. Example: DELETE /articles/1 HTTP/1.1
340+
/// Deletes an existing resource. Example: <code><![CDATA[
341+
/// DELETE /articles/1 HTTP/1.1
342+
/// ]]></code>
314343
/// </summary>
315344
public virtual async Task<IActionResult> DeleteAsync(TId id, CancellationToken cancellationToken)
316345
{
@@ -330,7 +359,9 @@ public virtual async Task<IActionResult> DeleteAsync(TId id, CancellationToken c
330359
}
331360

332361
/// <summary>
333-
/// Removes resources from a to-many relationship. Example: DELETE /articles/1/relationships/revisions HTTP/1.1
362+
/// Removes resources from a to-many relationship. Example: <code><![CDATA[
363+
/// DELETE /articles/1/relationships/revisions HTTP/1.1
364+
/// ]]></code>
334365
/// </summary>
335366
/// <param name="id">
336367
/// Identifies the left side of the relationship.

src/JsonApiDotNetCore/Middleware/IJsonApiRequest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ public interface IJsonApiRequest
1414
public EndpointKind Kind { get; }
1515

1616
/// <summary>
17-
/// The ID of the primary (top-level) resource for this request. This would be null in "/blogs", "123" in "/blogs/123" or "/blogs/123/author". This is
17+
/// The ID of the primary resource for this request. This would be <c>null</c> in "/blogs", "123" in "/blogs/123" or "/blogs/123/author". This is
1818
/// <c>null</c> before and after processing operations in an atomic:operations request.
1919
/// </summary>
2020
string? PrimaryId { get; }
2121

2222
/// <summary>
23-
/// The primary (top-level) resource type for this request. This would be "blogs" in "/blogs", "/blogs/123" or "/blogs/123/author". This is <c>null</c>
24-
/// before and after processing operations in an atomic:operations request.
23+
/// The primary resource type for this request. This would be "blogs" in "/blogs", "/blogs/123" or "/blogs/123/author". This is <c>null</c> before and
24+
/// after processing operations in an atomic:operations request.
2525
/// </summary>
2626
ResourceType? PrimaryResourceType { get; }
2727

2828
/// <summary>
29-
/// The secondary (nested) resource type for this request. This would be null in "/blogs", "/blogs/123" and "/blogs/123/unknownResource" or "people" in
29+
/// The secondary resource type for this request. This would be <c>null</c> in "/blogs", "/blogs/123" and "/blogs/123/unknownResource" or "people" in
3030
/// "/blogs/123/author" and "/blogs/123/relationships/author". This is <c>null</c> before and after processing operations in an atomic:operations
3131
/// request.
3232
/// </summary>
3333
ResourceType? SecondaryResourceType { get; }
3434

3535
/// <summary>
36-
/// The relationship for this nested request. This would be null in "/blogs", "/blogs/123" and "/blogs/123/unknownResource" or "author" in
36+
/// The relationship for this request. This would be <c>null</c> in "/blogs", "/blogs/123" and "/blogs/123/unknownResource" or "author" in
3737
/// "/blogs/123/author" and "/blogs/123/relationships/author". This is <c>null</c> before and after processing operations in an atomic:operations
3838
/// request.
3939
/// </summary>
@@ -45,13 +45,13 @@ public interface IJsonApiRequest
4545
bool IsCollection { get; }
4646

4747
/// <summary>
48-
/// Indicates whether this request targets only fetching of data (such as resources and relationships).
48+
/// Indicates whether this request targets only fetching of data (resources and relationships), as opposed to applying changes.
4949
/// </summary>
5050
bool IsReadOnly { get; }
5151

5252
/// <summary>
5353
/// In case of a non-readonly request, this indicates the kind of write operation currently being processed. This is <c>null</c> when processing a
54-
/// read-only operations, or before and after processing operations in an atomic:operations request.
54+
/// read-only operation, and before and after processing operations in an atomic:operations request.
5555
/// </summary>
5656
WriteOperationKind? WriteOperation { get; }
5757

test/TestBuildingBlocks/ObjectAssertionsExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static AndConstraint<NullableNumericAssertions<decimal>> BeApproximately(
6767
}
6868

6969
/// <summary>
70-
/// Used to assert on a JSON-formatted string, ignoring differences in insignificant whitespace and line endings.
70+
/// Asserts that a JSON-formatted string matches the specified expected one, ignoring differences in insignificant whitespace and line endings.
7171
/// </summary>
7272
[CustomAssertion]
7373
public static void BeJson(this StringAssertions source, string expected, string because = "", params object[] becauseArgs)

0 commit comments

Comments
 (0)