Skip to content

Commit d0256f0

Browse files
committed
Document JsonApiEndpoints enum
1 parent 6294e7a commit d0256f0

6 files changed

Lines changed: 241 additions & 7 deletions

File tree

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

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,142 @@
22

33
namespace JsonApiDotNetCore.Controllers;
44

5-
// IMPORTANT: An internal copy of this type exists in the SourceGenerators project. Keep these in sync when making changes.
5+
/// <summary>
6+
/// Lists the built-in JSON:API endpoints, described at https://jsonapi.org/format.
7+
/// </summary>
68
[PublicAPI]
79
[Flags]
810
public enum JsonApiEndpoints
911
{
12+
// IMPORTANT: An internal copy of this type exists in the JsonApiDotNetCore.SourceGenerators project.
13+
// Keep them in sync when making changes.
14+
15+
/// <summary>
16+
/// Represents none of the JSON:API endpoints.
17+
/// </summary>
1018
None = 0,
19+
20+
/// <summary>
21+
/// Represents the endpoint to get a collection of primary resources.
22+
/// <para>
23+
/// Example endpoint: <code language="http"><![CDATA[
24+
/// GET /articles HTTP/1.1
25+
/// ]]></code>
26+
/// </para>
27+
/// </summary>
1128
GetCollection = 1,
29+
30+
/// <summary>
31+
/// Represents the endpoint to get a single primary resource by ID.
32+
/// <para>
33+
/// Example endpoint: <code language="http"><![CDATA[
34+
/// GET /articles/1 HTTP/1.1
35+
/// ]]></code>
36+
/// </para>
37+
/// </summary>
1238
GetSingle = 1 << 1,
39+
40+
/// <summary>
41+
/// Represents the endpoint to get a secondary resource or collection of secondary resources.
42+
/// <para>
43+
/// Example endpoints: <code language="http"><![CDATA[
44+
/// GET /articles/1/author HTTP/1.1
45+
/// ]]></code>
46+
/// <code language="http"><![CDATA[
47+
/// GET /articles/1/revisions HTTP/1.1
48+
/// ]]></code>
49+
/// </para>
50+
/// </summary>
1351
GetSecondary = 1 << 2,
52+
53+
/// <summary>
54+
/// Represents the endpoint to get a relationship value.
55+
/// <para>
56+
/// Example endpoints: <code language="http"><![CDATA[
57+
/// GET /articles/1/relationships/author HTTP/1.1
58+
/// ]]></code>
59+
/// <code language="http"><![CDATA[
60+
/// GET /articles/1/relationships/revisions HTTP/1.1
61+
/// ]]></code>
62+
/// </para>
63+
/// </summary>
1464
GetRelationship = 1 << 3,
65+
66+
/// <summary>
67+
/// Represents the endpoint to create a new resource with attributes, relationships, or both.
68+
/// <para>
69+
/// Example endpoint: <code language="http"><![CDATA[
70+
/// POST /articles HTTP/1.1
71+
/// ]]></code>
72+
/// </para>
73+
/// </summary>
1574
Post = 1 << 4,
75+
76+
/// <summary>
77+
/// Represents the endpoint to add resources to a to-many relationship.
78+
/// <para>
79+
/// Example endpoint: <code language="http"><![CDATA[
80+
/// POST /articles/1/revisions HTTP/1.1
81+
/// ]]></code>
82+
/// </para>
83+
/// </summary>
1684
PostRelationship = 1 << 5,
85+
86+
/// <summary>
87+
/// Represents the endpoint to update the attributes and/or relationships of an existing resource.
88+
/// <para>
89+
/// Example endpoint: <code language="http"><![CDATA[
90+
/// PATCH /articles/1 HTTP/1.1
91+
/// ]]></code>
92+
/// </para>
93+
/// </summary>
1794
Patch = 1 << 6,
95+
96+
/// <summary>
97+
/// Represents the endpoint to perform a complete replacement of a relationship on an existing resource.
98+
/// <para>
99+
/// Example endpoints: <code language="http"><![CDATA[
100+
/// PATCH /articles/1/relationships/author HTTP/1.1
101+
/// ]]></code>
102+
/// <code language="http"><![CDATA[
103+
/// PATCH /articles/1/relationships/revisions HTTP/1.1
104+
/// ]]></code>
105+
/// </para>
106+
/// </summary>
18107
PatchRelationship = 1 << 7,
108+
109+
/// <summary>
110+
/// Represents the endpoint to delete an existing resource.
111+
/// <para>
112+
/// Example endpoint: <code language="http"><![CDATA[
113+
/// DELETE /articles/1 HTTP/1.1
114+
/// ]]></code>
115+
/// </para>
116+
/// </summary>
19117
Delete = 1 << 8,
118+
119+
/// <summary>
120+
/// Represents the endpoint to remove resources from a to-many relationship.
121+
/// <para>
122+
/// Example endpoint: <code language="http"><![CDATA[
123+
/// DELETE /articles/1/relationships/revisions HTTP/1.1
124+
/// ]]></code>
125+
/// </para>
126+
/// </summary>
20127
DeleteRelationship = 1 << 9,
21128

129+
/// <summary>
130+
/// Represents the set of JSON:API endpoints to query resources and relationships.
131+
/// </summary>
22132
Query = GetCollection | GetSingle | GetSecondary | GetRelationship,
133+
134+
/// <summary>
135+
/// Represents the set of JSON:API endpoints to change resources and relationships.
136+
/// </summary>
23137
Command = Post | PostRelationship | Patch | PatchRelationship | Delete | DeleteRelationship,
24138

139+
/// <summary>
140+
/// Represents all JSON:API endpoints.
141+
/// </summary>
25142
All = Query | Command
26143
}

src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,142 @@
22

33
namespace JsonApiDotNetCore.SourceGenerators;
44

5-
// IMPORTANT: A copy of this type exists in the JsonApiDotNetCore project. Keep these in sync when making changes.
5+
/// <summary>
6+
/// Lists the built-in JSON:API endpoints, described at https://jsonapi.org/format.
7+
/// </summary>
68
[PublicAPI]
79
[Flags]
810
public enum JsonApiEndpointsCopy
911
{
12+
// IMPORTANT: A copy of this type exists in the JsonApiDotNetCore.Annotations project.
13+
// Keep them in sync when making changes.
14+
15+
/// <summary>
16+
/// Represents none of the JSON:API endpoints.
17+
/// </summary>
1018
None = 0,
19+
20+
/// <summary>
21+
/// Represents the endpoint to get a collection of primary resources.
22+
/// <para>
23+
/// Example endpoint: <code language="http"><![CDATA[
24+
/// GET /articles HTTP/1.1
25+
/// ]]></code>
26+
/// </para>
27+
/// </summary>
1128
GetCollection = 1,
29+
30+
/// <summary>
31+
/// Represents the endpoint to get a single primary resource by ID.
32+
/// <para>
33+
/// Example endpoint: <code language="http"><![CDATA[
34+
/// GET /articles/1 HTTP/1.1
35+
/// ]]></code>
36+
/// </para>
37+
/// </summary>
1238
GetSingle = 1 << 1,
39+
40+
/// <summary>
41+
/// Represents the endpoint to get a secondary resource or collection of secondary resources.
42+
/// <para>
43+
/// Example endpoints: <code language="http"><![CDATA[
44+
/// GET /articles/1/author HTTP/1.1
45+
/// ]]></code>
46+
/// <code language="http"><![CDATA[
47+
/// GET /articles/1/revisions HTTP/1.1
48+
/// ]]></code>
49+
/// </para>
50+
/// </summary>
1351
GetSecondary = 1 << 2,
52+
53+
/// <summary>
54+
/// Represents the endpoint to get a relationship value.
55+
/// <para>
56+
/// Example endpoints: <code language="http"><![CDATA[
57+
/// GET /articles/1/relationships/author HTTP/1.1
58+
/// ]]></code>
59+
/// <code language="http"><![CDATA[
60+
/// GET /articles/1/relationships/revisions HTTP/1.1
61+
/// ]]></code>
62+
/// </para>
63+
/// </summary>
1464
GetRelationship = 1 << 3,
65+
66+
/// <summary>
67+
/// Represents the endpoint to create a new resource with attributes, relationships, or both.
68+
/// <para>
69+
/// Example endpoint: <code language="http"><![CDATA[
70+
/// POST /articles HTTP/1.1
71+
/// ]]></code>
72+
/// </para>
73+
/// </summary>
1574
Post = 1 << 4,
75+
76+
/// <summary>
77+
/// Represents the endpoint to add resources to a to-many relationship.
78+
/// <para>
79+
/// Example endpoint: <code language="http"><![CDATA[
80+
/// POST /articles/1/revisions HTTP/1.1
81+
/// ]]></code>
82+
/// </para>
83+
/// </summary>
1684
PostRelationship = 1 << 5,
85+
86+
/// <summary>
87+
/// Represents the endpoint to update the attributes and/or relationships of an existing resource.
88+
/// <para>
89+
/// Example endpoint: <code language="http"><![CDATA[
90+
/// PATCH /articles/1 HTTP/1.1
91+
/// ]]></code>
92+
/// </para>
93+
/// </summary>
1794
Patch = 1 << 6,
95+
96+
/// <summary>
97+
/// Represents the endpoint to perform a complete replacement of a relationship on an existing resource.
98+
/// <para>
99+
/// Example endpoints: <code language="http"><![CDATA[
100+
/// PATCH /articles/1/relationships/author HTTP/1.1
101+
/// ]]></code>
102+
/// <code language="http"><![CDATA[
103+
/// PATCH /articles/1/relationships/revisions HTTP/1.1
104+
/// ]]></code>
105+
/// </para>
106+
/// </summary>
18107
PatchRelationship = 1 << 7,
108+
109+
/// <summary>
110+
/// Represents the endpoint to delete an existing resource.
111+
/// <para>
112+
/// Example endpoint: <code language="http"><![CDATA[
113+
/// DELETE /articles/1 HTTP/1.1
114+
/// ]]></code>
115+
/// </para>
116+
/// </summary>
19117
Delete = 1 << 8,
118+
119+
/// <summary>
120+
/// Represents the endpoint to remove resources from a to-many relationship.
121+
/// <para>
122+
/// Example endpoint: <code language="http"><![CDATA[
123+
/// DELETE /articles/1/relationships/revisions HTTP/1.1
124+
/// ]]></code>
125+
/// </para>
126+
/// </summary>
20127
DeleteRelationship = 1 << 9,
21128

129+
/// <summary>
130+
/// Represents the set of JSON:API endpoints to query resources and relationships.
131+
/// </summary>
22132
Query = GetCollection | GetSingle | GetSecondary | GetRelationship,
133+
134+
/// <summary>
135+
/// Represents the set of JSON:API endpoints to change resources and relationships.
136+
/// </summary>
23137
Command = Post | PostRelationship | Patch | PatchRelationship | Delete | DeleteRelationship,
24138

139+
/// <summary>
140+
/// Represents all JSON:API endpoints.
141+
/// </summary>
25142
All = Query | Command
26143
}

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)