Skip to content

Commit 3e6ea09

Browse files
committed
Document JsonApiEndpoints enum
1 parent 6294e7a commit 3e6ea09

6 files changed

Lines changed: 229 additions & 5 deletions

File tree

src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,132 @@ namespace JsonApiDotNetCore.Controllers;
77
[Flags]
88
public enum JsonApiEndpoints
99
{
10+
/// <summary>
11+
/// Represents none of the JSON:API endpoints.
12+
/// </summary>
1013
None = 0,
14+
15+
/// <summary>
16+
/// Represents the endpoint to get a collection of primary resources.
17+
/// <para>
18+
/// Example endpoint: <code language="http"><![CDATA[
19+
/// GET /articles HTTP/1.1
20+
/// ]]></code>
21+
/// </para>
22+
/// </summary>
1123
GetCollection = 1,
24+
25+
/// <summary>
26+
/// Represents the endpoint to get a single primary resource by ID.
27+
/// <para>
28+
/// Example endpoint: <code language="http"><![CDATA[
29+
/// GET /articles/1 HTTP/1.1
30+
/// ]]></code>
31+
/// </para>
32+
/// </summary>
1233
GetSingle = 1 << 1,
34+
35+
/// <summary>
36+
/// Represents the endpoint to get a secondary resource or collection of secondary resources.
37+
/// <para>
38+
/// Example endpoints: <code language="http"><![CDATA[
39+
/// GET /articles/1/author HTTP/1.1
40+
/// ]]></code>
41+
/// <code language="http"><![CDATA[
42+
/// GET /articles/1/revisions HTTP/1.1
43+
/// ]]></code>
44+
/// </para>
45+
/// </summary>
1346
GetSecondary = 1 << 2,
47+
48+
/// <summary>
49+
/// Represents the endpoint to get a relationship value.
50+
/// <para>
51+
/// Example endpoints: <code language="http"><![CDATA[
52+
/// GET /articles/1/relationships/author HTTP/1.1
53+
/// ]]></code>
54+
/// <code language="http"><![CDATA[
55+
/// GET /articles/1/relationships/revisions HTTP/1.1
56+
/// ]]></code>
57+
/// </para>
58+
/// </summary>
1459
GetRelationship = 1 << 3,
60+
61+
/// <summary>
62+
/// Represents the endpoint to create a new resource with attributes, relationships, or both.
63+
/// <para>
64+
/// Example endpoint: <code language="http"><![CDATA[
65+
/// POST /articles HTTP/1.1
66+
/// ]]></code>
67+
/// </para>
68+
/// </summary>
1569
Post = 1 << 4,
70+
71+
/// <summary>
72+
/// Represents the endpoint to add resources to a to-many relationship.
73+
/// <para>
74+
/// Example endpoint: <code language="http"><![CDATA[
75+
/// POST /articles/1/revisions HTTP/1.1
76+
/// ]]></code>
77+
/// </para>
78+
/// </summary>
1679
PostRelationship = 1 << 5,
80+
81+
/// <summary>
82+
/// Represents the endpoint to update the attributes and/or relationships of an existing resource.
83+
/// <para>
84+
/// Example endpoint: <code language="http"><![CDATA[
85+
/// PATCH /articles/1 HTTP/1.1
86+
/// ]]></code>
87+
/// </para>
88+
/// </summary>
1789
Patch = 1 << 6,
90+
91+
/// <summary>
92+
/// Represents the endpoint to perform a complete replacement of a relationship on an existing resource.
93+
/// <para>
94+
/// Example endpoints: <code language="http"><![CDATA[
95+
/// PATCH /articles/1/relationships/author HTTP/1.1
96+
/// ]]></code>
97+
/// <code language="http"><![CDATA[
98+
/// PATCH /articles/1/relationships/revisions HTTP/1.1
99+
/// ]]></code>
100+
/// </para>
101+
/// </summary>
18102
PatchRelationship = 1 << 7,
103+
104+
/// <summary>
105+
/// Represents the endpoint to delete an existing resource.
106+
/// <para>
107+
/// Example endpoint: <code language="http"><![CDATA[
108+
/// DELETE /articles/1 HTTP/1.1
109+
/// ]]></code>
110+
/// </para>
111+
/// </summary>
19112
Delete = 1 << 8,
113+
114+
/// <summary>
115+
/// Represents the endpoint to remove resources from a to-many relationship.
116+
/// <para>
117+
/// Example endpoint: <code language="http"><![CDATA[
118+
/// DELETE /articles/1/relationships/revisions HTTP/1.1
119+
/// ]]></code>
120+
/// </para>
121+
/// </summary>
20122
DeleteRelationship = 1 << 9,
21123

124+
/// <summary>
125+
/// Represents the set of JSON:API endpoints to query resources and relationships.
126+
/// </summary>
22127
Query = GetCollection | GetSingle | GetSecondary | GetRelationship,
128+
129+
/// <summary>
130+
/// Represents the set of JSON:API endpoints to change resources and relationships.
131+
/// </summary>
23132
Command = Post | PostRelationship | Patch | PatchRelationship | Delete | DeleteRelationship,
24133

134+
/// <summary>
135+
/// Represents all JSON:API endpoints.
136+
/// </summary>
25137
All = Query | Command
26138
}

src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,132 @@ namespace JsonApiDotNetCore.SourceGenerators;
77
[Flags]
88
public enum JsonApiEndpointsCopy
99
{
10+
/// <summary>
11+
/// Represents none of the JSON:API endpoints.
12+
/// </summary>
1013
None = 0,
14+
15+
/// <summary>
16+
/// Represents the endpoint to get a collection of primary resources.
17+
/// <para>
18+
/// Example endpoint: <code language="http"><![CDATA[
19+
/// GET /articles HTTP/1.1
20+
/// ]]></code>
21+
/// </para>
22+
/// </summary>
1123
GetCollection = 1,
24+
25+
/// <summary>
26+
/// Represents the endpoint to get a single primary resource by ID.
27+
/// <para>
28+
/// Example endpoint: <code language="http"><![CDATA[
29+
/// GET /articles/1 HTTP/1.1
30+
/// ]]></code>
31+
/// </para>
32+
/// </summary>
1233
GetSingle = 1 << 1,
34+
35+
/// <summary>
36+
/// Represents the endpoint to get a secondary resource or collection of secondary resources.
37+
/// <para>
38+
/// Example endpoints: <code language="http"><![CDATA[
39+
/// GET /articles/1/author HTTP/1.1
40+
/// ]]></code>
41+
/// <code language="http"><![CDATA[
42+
/// GET /articles/1/revisions HTTP/1.1
43+
/// ]]></code>
44+
/// </para>
45+
/// </summary>
1346
GetSecondary = 1 << 2,
47+
48+
/// <summary>
49+
/// Represents the endpoint to get a relationship value.
50+
/// <para>
51+
/// Example endpoints: <code language="http"><![CDATA[
52+
/// GET /articles/1/relationships/author HTTP/1.1
53+
/// ]]></code>
54+
/// <code language="http"><![CDATA[
55+
/// GET /articles/1/relationships/revisions HTTP/1.1
56+
/// ]]></code>
57+
/// </para>
58+
/// </summary>
1459
GetRelationship = 1 << 3,
60+
61+
/// <summary>
62+
/// Represents the endpoint to create a new resource with attributes, relationships, or both.
63+
/// <para>
64+
/// Example endpoint: <code language="http"><![CDATA[
65+
/// POST /articles HTTP/1.1
66+
/// ]]></code>
67+
/// </para>
68+
/// </summary>
1569
Post = 1 << 4,
70+
71+
/// <summary>
72+
/// Represents the endpoint to add resources to a to-many relationship.
73+
/// <para>
74+
/// Example endpoint: <code language="http"><![CDATA[
75+
/// POST /articles/1/revisions HTTP/1.1
76+
/// ]]></code>
77+
/// </para>
78+
/// </summary>
1679
PostRelationship = 1 << 5,
80+
81+
/// <summary>
82+
/// Represents the endpoint to update the attributes and/or relationships of an existing resource.
83+
/// <para>
84+
/// Example endpoint: <code language="http"><![CDATA[
85+
/// PATCH /articles/1 HTTP/1.1
86+
/// ]]></code>
87+
/// </para>
88+
/// </summary>
1789
Patch = 1 << 6,
90+
91+
/// <summary>
92+
/// Represents the endpoint to perform a complete replacement of a relationship on an existing resource.
93+
/// <para>
94+
/// Example endpoints: <code language="http"><![CDATA[
95+
/// PATCH /articles/1/relationships/author HTTP/1.1
96+
/// ]]></code>
97+
/// <code language="http"><![CDATA[
98+
/// PATCH /articles/1/relationships/revisions HTTP/1.1
99+
/// ]]></code>
100+
/// </para>
101+
/// </summary>
18102
PatchRelationship = 1 << 7,
103+
104+
/// <summary>
105+
/// Represents the endpoint to delete an existing resource.
106+
/// <para>
107+
/// Example endpoint: <code language="http"><![CDATA[
108+
/// DELETE /articles/1 HTTP/1.1
109+
/// ]]></code>
110+
/// </para>
111+
/// </summary>
19112
Delete = 1 << 8,
113+
114+
/// <summary>
115+
/// Represents the endpoint to remove resources from a to-many relationship.
116+
/// <para>
117+
/// Example endpoint: <code language="http"><![CDATA[
118+
/// DELETE /articles/1/relationships/revisions HTTP/1.1
119+
/// ]]></code>
120+
/// </para>
121+
/// </summary>
20122
DeleteRelationship = 1 << 9,
21123

124+
/// <summary>
125+
/// Represents the set of JSON:API endpoints to query resources and relationships.
126+
/// </summary>
22127
Query = GetCollection | GetSingle | GetSecondary | GetRelationship,
128+
129+
/// <summary>
130+
/// Represents the set of JSON:API endpoints to change resources and relationships.
131+
/// </summary>
23132
Command = Post | PostRelationship | Patch | PatchRelationship | Delete | DeleteRelationship,
24133

134+
/// <summary>
135+
/// Represents all JSON:API endpoints.
136+
/// </summary>
25137
All = Query | Command
26138
}

src/JsonApiDotNetCore/AtomicOperations/Processors/ICreateProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace JsonApiDotNetCore.AtomicOperations.Processors;
77

88
/// <summary>
9-
/// Processes a single operation to create a new resource with attributes, relationships or both.
9+
/// Processes a single operation to create a new resource with attributes, relationships, or both.
1010
/// </summary>
1111
/// <typeparam name="TResource">
1212
/// The resource type.

src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public virtual async Task<IActionResult> GetSecondaryAsync([DisallowNull] TId id
165165
}
166166

167167
/// <summary>
168-
/// Gets a relationship value, which can be a <c>null</c>, a single object or a collection.
168+
/// Gets a relationship value, which can be <c>null</c>, a single object or a collection.
169169
/// <para>
170170
/// Example endpoints: <code language="http"><![CDATA[
171171
/// GET /articles/1/relationships/author HTTP/1.1
@@ -197,7 +197,7 @@ public virtual async Task<IActionResult> GetRelationshipAsync([DisallowNull] TId
197197
}
198198

199199
/// <summary>
200-
/// Creates a new resource with attributes, relationships or both.
200+
/// Creates a new resource with attributes, relationships, or both.
201201
/// <para>
202202
/// Example endpoint: <code language="http"><![CDATA[
203203
/// POST /articles HTTP/1.1

src/JsonApiDotNetCore/Middleware/WriteOperationKind.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace JsonApiDotNetCore.Middleware;
77
public enum WriteOperationKind
88
{
99
/// <summary>
10-
/// Create a new resource with attributes, relationships or both.
10+
/// Create a new resource with attributes, relationships, or both.
1111
/// </summary>
1212
CreateResource,
1313

src/JsonApiDotNetCore/Services/ICreateService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public interface ICreateService<TResource, in TId>
77
where TResource : class, IIdentifiable<TId>
88
{
99
/// <summary>
10-
/// Handles a JSON:API request to create a new resource with attributes, relationships or both.
10+
/// Handles a JSON:API request to create a new resource with attributes, relationships, or both.
1111
/// </summary>
1212
Task<TResource?> CreateAsync(TResource resource, CancellationToken cancellationToken);
1313
}

0 commit comments

Comments
 (0)