From b7d77eaef4b1a264ac181d80dea5fbf4983eab09 Mon Sep 17 00:00:00 2001 From: verdie-g Date: Sun, 20 Aug 2023 15:54:51 -0400 Subject: [PATCH 1/6] Document JsonApiEndpoints enum (#1298) --- .../Controllers/JsonApiEndpoints.shared.cs | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs b/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs index 92ba933fe3..ed93255b02 100644 --- a/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs +++ b/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs @@ -11,19 +11,81 @@ namespace JsonApiDotNetCore.Controllers; public enum JsonApiEndpoints { None = 0, + + /// + /// Endpoint to get a collection of primary resources. + /// + /// GetCollection = 1, + + /// + /// Endpoint to get a single primary resource by ID. + /// + /// GetSingle = 1 << 1, + + /// + /// Endpoint to get a secondary resource or collection of secondary resources. + /// + /// GetSecondary = 1 << 2, + + /// + /// Endpoint to get a relationship value, which can be a null, a single object or a collection. + /// + /// + /// GetRelationship = 1 << 3, + + /// + /// Endpoint to creates a new resource with attributes, relationships or both. + /// + /// Post = 1 << 4, + + /// + /// Endpoint to add resources to a to-many relationship. + /// + /// PostRelationship = 1 << 5, + + /// + /// Endpoint to update the attributes and/or relationships of an existing resource. + /// + /// Patch = 1 << 6, + + /// + /// Endpoint to perform a complete replacement of a relationship on an existing resource. + /// + /// + /// PatchRelationship = 1 << 7, + + /// + /// Endpoint to delete an existing resource. + /// + /// Delete = 1 << 8, + + /// + /// Endpoint to remove resources from a to-many relationship. + /// + /// DeleteRelationship = 1 << 9, + /// + /// All read-only endpoints. + /// Query = GetCollection | GetSingle | GetSecondary | GetRelationship, + + /// + /// All write endpoints. + /// Command = Post | PostRelationship | Patch | PatchRelationship | Delete | DeleteRelationship, + /// + /// All endpoints. + /// All = Query | Command } From ab98e677934ed407cd4e3b45193c336a82e93833 Mon Sep 17 00:00:00 2001 From: verdie-g Date: Sun, 20 Aug 2023 17:12:43 -0400 Subject: [PATCH 2/6] fix coding style --- .../Controllers/JsonApiEndpoints.shared.cs | 48 ++++++++++++++----- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs b/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs index ed93255b02..cbee8b8cbb 100644 --- a/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs +++ b/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs @@ -15,63 +15,87 @@ public enum JsonApiEndpoints /// /// Endpoint to get a collection of primary resources. /// - /// + /// + /// + /// GetCollection = 1, /// /// Endpoint to get a single primary resource by ID. /// - /// + /// + /// + /// GetSingle = 1 << 1, /// /// Endpoint to get a secondary resource or collection of secondary resources. /// - /// + /// + /// + /// GetSecondary = 1 << 2, /// /// Endpoint to get a relationship value, which can be a null, a single object or a collection. /// - /// - /// + /// + /// + /// + /// + /// + /// GetRelationship = 1 << 3, /// /// Endpoint to creates a new resource with attributes, relationships or both. /// - /// + /// + /// + /// Post = 1 << 4, /// /// Endpoint to add resources to a to-many relationship. /// - /// + /// + /// + /// PostRelationship = 1 << 5, /// /// Endpoint to update the attributes and/or relationships of an existing resource. /// - /// + /// + /// + /// Patch = 1 << 6, /// /// Endpoint to perform a complete replacement of a relationship on an existing resource. /// - /// - /// + /// + /// + /// + /// + /// + /// PatchRelationship = 1 << 7, /// /// Endpoint to delete an existing resource. /// - /// + /// + /// + /// Delete = 1 << 8, /// /// Endpoint to remove resources from a to-many relationship. /// - /// + /// + /// + /// DeleteRelationship = 1 << 9, /// From 1e5ede082b61886fa02449ad9864ec889881660a Mon Sep 17 00:00:00 2001 From: verdie-g Date: Sat, 2 Sep 2023 20:13:12 -0400 Subject: [PATCH 3/6] Address PR comments --- .../Controllers/JsonApiEndpoints.shared.cs | 91 +++++++++---------- .../JsonApiEndpointsCopy.cs | 81 ++++++++++++++++- 2 files changed, 122 insertions(+), 50 deletions(-) diff --git a/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs b/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs index cbee8b8cbb..93bcd87c5a 100644 --- a/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs +++ b/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs @@ -10,106 +10,99 @@ namespace JsonApiDotNetCore.Controllers; [Flags] public enum JsonApiEndpoints { + /// + /// Represents none of the JSON:API endpoints. + /// None = 0, /// - /// Endpoint to get a collection of primary resources. + /// Represents the endpoint to get a collection of primary resources. Example: /// - /// - /// - /// GetCollection = 1, /// - /// Endpoint to get a single primary resource by ID. + /// Represents the endpoint to get a single primary resource by ID. Example: /// - /// - /// - /// GetSingle = 1 << 1, /// - /// Endpoint to get a secondary resource or collection of secondary resources. + /// Represents the endpoint to get a secondary resource or collection of secondary resources. Example: /// - /// - /// - /// GetSecondary = 1 << 2, /// - /// Endpoint to get a relationship value, which can be a null, a single object or a collection. + /// Represents the endpoint to get a relationship value. Example: Example: + /// /// - /// - /// - /// - /// - /// - /// GetRelationship = 1 << 3, /// - /// Endpoint to creates a new resource with attributes, relationships or both. + /// Represents the endpoint to creates a new resource with attributes, relationships or both. Example: /// - /// - /// - /// Post = 1 << 4, /// - /// Endpoint to add resources to a to-many relationship. + /// Represents the endpoint to add resources to a to-many relationship. Example: /// - /// - /// - /// PostRelationship = 1 << 5, /// - /// Endpoint to update the attributes and/or relationships of an existing resource. + /// Represents the endpoint to update the attributes and/or relationships of an existing resource. Example: /// - /// - /// - /// Patch = 1 << 6, /// - /// Endpoint to perform a complete replacement of a relationship on an existing resource. + /// Represents the endpoint to perform a complete replacement of a relationship on an existing resource. Example: Example: + /// /// - /// - /// - /// - /// - /// - /// PatchRelationship = 1 << 7, /// - /// Endpoint to delete an existing resource. + /// Represents the endpoint to delete an existing resource. Example: /// - /// - /// - /// Delete = 1 << 8, /// - /// Endpoint to remove resources from a to-many relationship. + /// Represents the endpoint to remove resources from a to-many relationship. Example: /// - /// - /// - /// DeleteRelationship = 1 << 9, /// - /// All read-only endpoints. + /// Represents the set of JSON:API endpoints to query resources and relationships. /// Query = GetCollection | GetSingle | GetSecondary | GetRelationship, /// - /// All write endpoints. + /// Represents the set of JSON:API endpoints to change resources and relationships. /// Command = Post | PostRelationship | Patch | PatchRelationship | Delete | DeleteRelationship, /// - /// All endpoints. + /// Represents all of the JSON:API endpoints. /// All = Query | Command } diff --git a/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs b/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs index 911be3f359..b34062ae30 100644 --- a/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs +++ b/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs @@ -2,22 +2,101 @@ namespace JsonApiDotNetCore.SourceGenerators; // IMPORTANT: A copy of this type exists in the JsonApiDotNetCore project. Keep these in sync when making changes. [Flags] -public enum JsonApiEndpointsCopy +public enum JsonApiEndpoints { + /// + /// Represents none of the JSON:API endpoints. + /// None = 0, + + /// + /// Represents the endpoint to get a collection of primary resources. Example: + /// GetCollection = 1, + + /// + /// Represents the endpoint to get a single primary resource by ID. Example: + /// GetSingle = 1 << 1, + + /// + /// Represents the endpoint to get a secondary resource or collection of secondary resources. Example: + /// GetSecondary = 1 << 2, + + /// + /// Represents the endpoint to get a relationship value. Example: Example: + /// + /// GetRelationship = 1 << 3, + + /// + /// Represents the endpoint to creates a new resource with attributes, relationships or both. Example: + /// Post = 1 << 4, + + /// + /// Represents the endpoint to add resources to a to-many relationship. Example: + /// PostRelationship = 1 << 5, + + /// + /// Represents the endpoint to update the attributes and/or relationships of an existing resource. Example: + /// Patch = 1 << 6, + + /// + /// Represents the endpoint to perform a complete replacement of a relationship on an existing resource. Example: Example: + /// + /// PatchRelationship = 1 << 7, + + /// + /// Represents the endpoint to delete an existing resource. Example: + /// Delete = 1 << 8, + + /// + /// Represents the endpoint to remove resources from a to-many relationship. Example: + /// DeleteRelationship = 1 << 9, + /// + /// Represents the set of JSON:API endpoints to query resources and relationships. + /// Query = GetCollection | GetSingle | GetSecondary | GetRelationship, + + /// + /// Represents the set of JSON:API endpoints to change resources and relationships. + /// Command = Post | PostRelationship | Patch | PatchRelationship | Delete | DeleteRelationship, + /// + /// Represents all of the JSON:API endpoints. + /// All = Query | Command } From a56e1f4d38cf119144d15a50ef4c79541c6c4c3a Mon Sep 17 00:00:00 2001 From: verdie-g Date: Sun, 3 Sep 2023 11:38:28 -0400 Subject: [PATCH 4/6] Fix copy name --- src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs b/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs index b34062ae30..9d01b8f85c 100644 --- a/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs +++ b/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs @@ -2,7 +2,7 @@ namespace JsonApiDotNetCore.SourceGenerators; // IMPORTANT: A copy of this type exists in the JsonApiDotNetCore project. Keep these in sync when making changes. [Flags] -public enum JsonApiEndpoints +public enum JsonApiEndpointsCopy { /// /// Represents none of the JSON:API endpoints. From e2ec1c43124791a3d2853e5131a5fa4765029ad4 Mon Sep 17 00:00:00 2001 From: verdie-g Date: Sun, 3 Sep 2023 15:50:47 -0400 Subject: [PATCH 5/6] Run cleanupcode --- .../Controllers/JsonApiEndpoints.shared.cs | 15 ++++++++++----- .../JsonApiEndpointsCopy.cs | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs b/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs index 93bcd87c5a..b0ae6dddc2 100644 --- a/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs +++ b/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs @@ -30,7 +30,8 @@ public enum JsonApiEndpoints GetSingle = 1 << 1, /// - /// Represents the endpoint to get a secondary resource or collection of secondary resources. Example: /// @@ -47,7 +48,8 @@ public enum JsonApiEndpoints GetRelationship = 1 << 3, /// - /// Represents the endpoint to creates a new resource with attributes, relationships or both. Example: /// @@ -61,14 +63,16 @@ public enum JsonApiEndpoints PostRelationship = 1 << 5, /// - /// Represents the endpoint to update the attributes and/or relationships of an existing resource. Example: /// Patch = 1 << 6, /// - /// Represents the endpoint to perform a complete replacement of a relationship on an existing resource. Example: Example: /// - /// Represents the endpoint to remove resources from a to-many relationship. Example: /// diff --git a/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs b/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs index 9d01b8f85c..3425748506 100644 --- a/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs +++ b/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs @@ -24,7 +24,8 @@ public enum JsonApiEndpointsCopy GetSingle = 1 << 1, /// - /// Represents the endpoint to get a secondary resource or collection of secondary resources. Example: /// @@ -41,7 +42,8 @@ public enum JsonApiEndpointsCopy GetRelationship = 1 << 3, /// - /// Represents the endpoint to creates a new resource with attributes, relationships or both. Example: /// @@ -55,14 +57,16 @@ public enum JsonApiEndpointsCopy PostRelationship = 1 << 5, /// - /// Represents the endpoint to update the attributes and/or relationships of an existing resource. Example: /// Patch = 1 << 6, /// - /// Represents the endpoint to perform a complete replacement of a relationship on an existing resource. Example: Example: /// - /// Represents the endpoint to remove resources from a to-many relationship. Example: /// From 748d2dface62e325a6e953eed6c5c9e8c90bda8b Mon Sep 17 00:00:00 2001 From: verdie-g Date: Sun, 3 Sep 2023 18:51:16 -0400 Subject: [PATCH 6/6] Address PR comments --- .../Controllers/JsonApiEndpoints.shared.cs | 4 +++- .../JsonApiEndpointsCopy.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs b/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs index b0ae6dddc2..1ee992f9b2 100644 --- a/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs +++ b/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs @@ -33,6 +33,8 @@ public enum JsonApiEndpoints /// Represents the endpoint to get a secondary resource or collection of secondary resources. Example: /// Example: /// GetSecondary = 1 << 2, @@ -48,7 +50,7 @@ public enum JsonApiEndpoints GetRelationship = 1 << 3, /// - /// Represents the endpoint to creates a new resource with attributes, relationships or both. Example: + /// Represents the endpoint to create a new resource with attributes, relationships or both. Example: /// diff --git a/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs b/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs index 3425748506..862892a77f 100644 --- a/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs +++ b/src/JsonApiDotNetCore.SourceGenerators/JsonApiEndpointsCopy.cs @@ -27,6 +27,8 @@ public enum JsonApiEndpointsCopy /// Represents the endpoint to get a secondary resource or collection of secondary resources. Example: /// Example: /// GetSecondary = 1 << 2, @@ -42,7 +44,7 @@ public enum JsonApiEndpointsCopy GetRelationship = 1 << 3, /// - /// Represents the endpoint to creates a new resource with attributes, relationships or both. Example: + /// Represents the endpoint to create a new resource with attributes, relationships or both. Example: ///