diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/NullableSecondaryResourceResponseDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/NullableSecondaryResourceResponseDocument.cs index 4f86562323..b1cfe45062 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/NullableSecondaryResourceResponseDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/NullableSecondaryResourceResponseDocument.cs @@ -8,7 +8,7 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents { [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class NullableSecondaryResourceResponseDocument : NullableSingleData> + internal sealed class NullableSecondaryResourceResponseDocument : NullableSingleData> where TResource : IIdentifiable { public IDictionary Meta { get; set; } = null!; diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/PrimaryResourceResponseDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/PrimaryResourceResponseDocument.cs index d7c2ee83e3..76b47786d2 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/PrimaryResourceResponseDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/PrimaryResourceResponseDocument.cs @@ -10,7 +10,7 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents // Types in the current namespace are never touched by ASP.NET ModelState validation, therefore using a non-nullable reference type for a property does not // imply this property is required. Instead, we use [Required] explicitly, because this is how Swashbuckle is instructed to mark properties as required. [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class PrimaryResourceResponseDocument : SingleData> + internal sealed class PrimaryResourceResponseDocument : SingleData> where TResource : IIdentifiable { public IDictionary Meta { get; set; } = null!; diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceCollectionResponseDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceCollectionResponseDocument.cs index 4b90acec0e..97d35c0156 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceCollectionResponseDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceCollectionResponseDocument.cs @@ -8,7 +8,7 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents { [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class ResourceCollectionResponseDocument : ManyData> + internal sealed class ResourceCollectionResponseDocument : ManyData> where TResource : IIdentifiable { public IDictionary Meta { get; set; } = null!; diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourcePatchRequestDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourcePatchRequestDocument.cs index 7246695ccd..6a5e7615c5 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourcePatchRequestDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourcePatchRequestDocument.cs @@ -5,7 +5,7 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents { [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class ResourcePatchRequestDocument : SingleData> + internal sealed class ResourcePatchRequestDocument : SingleData> where TResource : IIdentifiable { } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourcePostRequestDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourcePostRequestDocument.cs index 034863b5cf..2459cef0eb 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourcePostRequestDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourcePostRequestDocument.cs @@ -5,7 +5,7 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents { [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class ResourcePostRequestDocument : SingleData> + internal sealed class ResourcePostRequestDocument : SingleData> where TResource : IIdentifiable { } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/SecondaryResourceResponseDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/SecondaryResourceResponseDocument.cs index 6a2fbae85b..73698b6351 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/SecondaryResourceResponseDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/SecondaryResourceResponseDocument.cs @@ -8,7 +8,7 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents { [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class SecondaryResourceResponseDocument : SingleData> + internal sealed class SecondaryResourceResponseDocument : SingleData> where TResource : IIdentifiable { public IDictionary Meta { get; set; } = null!; diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/NonPrimaryDocumentTypeFactory.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/NonPrimaryDocumentTypeFactory.cs index 54a3d82bf3..9b213ca336 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/NonPrimaryDocumentTypeFactory.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/NonPrimaryDocumentTypeFactory.cs @@ -1,6 +1,6 @@ using System; using JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; -using JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData; +using JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships; using JsonApiDotNetCore.Resources.Annotations; namespace JsonApiDotNetCore.OpenApi.JsonApiObjects @@ -10,8 +10,8 @@ internal sealed class NonPrimaryDocumentTypeFactory private static readonly DocumentOpenTypes SecondaryResponseDocumentOpenTypes = new(typeof(ResourceCollectionResponseDocument<>), typeof(NullableSecondaryResourceResponseDocument<>), typeof(SecondaryResourceResponseDocument<>)); - private static readonly DocumentOpenTypes RelationshipRequestDocumentOpenTypes = new(typeof(ToManyRelationshipRequestData<>), - typeof(NullableToOneRelationshipRequestData<>), typeof(ToOneRelationshipRequestData<>)); + private static readonly DocumentOpenTypes RelationshipRequestDocumentOpenTypes = new(typeof(ToManyRelationshipInRequest<>), + typeof(NullableToOneRelationshipInRequest<>), typeof(ToOneRelationshipInRequest<>)); private static readonly DocumentOpenTypes RelationshipResponseDocumentOpenTypes = new(typeof(ResourceIdentifierCollectionResponseDocument<>), typeof(NullableResourceIdentifierResponseDocument<>), typeof(ResourceIdentifierResponseDocument<>)); diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipDataTypeFactory.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipTypeFactory.cs similarity index 67% rename from src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipDataTypeFactory.cs rename to src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipTypeFactory.cs index dde79ca61a..4a2dc2775d 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipDataTypeFactory.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipTypeFactory.cs @@ -1,14 +1,14 @@ using System; -using JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData; +using JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships; using JsonApiDotNetCore.Resources.Annotations; namespace JsonApiDotNetCore.OpenApi.JsonApiObjects { - internal sealed class RelationshipDataTypeFactory + internal sealed class RelationshipTypeFactory { - public static RelationshipDataTypeFactory Instance { get; } = new(); + public static RelationshipTypeFactory Instance { get; } = new(); - private RelationshipDataTypeFactory() + private RelationshipTypeFactory() { } @@ -26,10 +26,10 @@ public Type GetForResponse(RelationshipAttribute relationship) // @formatter:nested_ternary_style expanded Type relationshipDataOpenType = relationship is HasManyAttribute - ? typeof(ToManyRelationshipResponseData<>) + ? typeof(ToManyRelationshipInResponse<>) : relationship.IsNullable() - ? typeof(NullableToOneRelationshipResponseData<>) - : typeof(ToOneRelationshipResponseData<>); + ? typeof(NullableToOneRelationshipInResponse<>) + : typeof(ToOneRelationshipInResponse<>); // @formatter:nested_ternary_style restore diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/NullableToOneRelationshipRequestData.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/NullableToOneRelationshipInRequest.cs similarity index 54% rename from src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/NullableToOneRelationshipRequestData.cs rename to src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/NullableToOneRelationshipInRequest.cs index a6163ab358..7c21bee5d8 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/NullableToOneRelationshipRequestData.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/NullableToOneRelationshipInRequest.cs @@ -2,10 +2,10 @@ using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; using JsonApiDotNetCore.Resources; -namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData +namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships { [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class NullableToOneRelationshipRequestData : NullableSingleData> + internal sealed class NullableToOneRelationshipInRequest : NullableSingleData> where TResource : IIdentifiable { } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/NullableToOneRelationshipResponseData.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/NullableToOneRelationshipInResponse.cs similarity index 72% rename from src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/NullableToOneRelationshipResponseData.cs rename to src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/NullableToOneRelationshipInResponse.cs index 7e2c8714ba..795d5a503b 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/NullableToOneRelationshipResponseData.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/NullableToOneRelationshipInResponse.cs @@ -5,10 +5,10 @@ using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; using JsonApiDotNetCore.Resources; -namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData +namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships { [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class NullableToOneRelationshipResponseData : NullableSingleData> + internal sealed class NullableToOneRelationshipInResponse : NullableSingleData> where TResource : IIdentifiable { [Required] diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/ToManyRelationshipRequestData.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/ToManyRelationshipInRequest.cs similarity index 56% rename from src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/ToManyRelationshipRequestData.cs rename to src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/ToManyRelationshipInRequest.cs index 0d29dd496a..51570a56f4 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/ToManyRelationshipRequestData.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/ToManyRelationshipInRequest.cs @@ -2,10 +2,10 @@ using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; using JsonApiDotNetCore.Resources; -namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData +namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships { [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class ToManyRelationshipRequestData : ManyData> + internal sealed class ToManyRelationshipInRequest : ManyData> where TResource : IIdentifiable { } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/ToManyRelationshipResponseData.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/ToManyRelationshipInResponse.cs similarity index 74% rename from src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/ToManyRelationshipResponseData.cs rename to src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/ToManyRelationshipInResponse.cs index eb5eb2d1ac..90e88d334e 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/ToManyRelationshipResponseData.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/ToManyRelationshipInResponse.cs @@ -5,10 +5,10 @@ using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; using JsonApiDotNetCore.Resources; -namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData +namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships { [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class ToManyRelationshipResponseData : ManyData> + internal sealed class ToManyRelationshipInResponse : ManyData> where TResource : IIdentifiable { [Required] diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/ToOneRelationshipRequestData.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/ToOneRelationshipInRequest.cs similarity index 56% rename from src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/ToOneRelationshipRequestData.cs rename to src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/ToOneRelationshipInRequest.cs index 1526768c31..0d95b0efb2 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/ToOneRelationshipRequestData.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/ToOneRelationshipInRequest.cs @@ -2,10 +2,10 @@ using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; using JsonApiDotNetCore.Resources; -namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData +namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships { [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class ToOneRelationshipRequestData : SingleData> + internal sealed class ToOneRelationshipInRequest : SingleData> where TResource : IIdentifiable { } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/ToOneRelationshipResponseData.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/ToOneRelationshipInResponse.cs similarity index 74% rename from src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/ToOneRelationshipResponseData.cs rename to src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/ToOneRelationshipInResponse.cs index 02798adee8..491c42740e 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/RelationshipData/ToOneRelationshipResponseData.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Relationships/ToOneRelationshipInResponse.cs @@ -5,10 +5,10 @@ using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; using JsonApiDotNetCore.Resources; -namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData +namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships { [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class ToOneRelationshipResponseData : SingleData> + internal sealed class ToOneRelationshipInResponse : SingleData> where TResource : IIdentifiable { [Required] diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/AttributesInPatchRequest.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/AttributesInPatchRequest.cs new file mode 100644 index 0000000000..84e4c3cc5b --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/AttributesInPatchRequest.cs @@ -0,0 +1,10 @@ +using JsonApiDotNetCore.Resources; + +namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects +{ + // ReSharper disable once UnusedTypeParameter + internal sealed class AttributesInPatchRequest + where TResource : IIdentifiable + { + } +} diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourcePostRequestObject.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/AttributesInPostRequest.cs similarity index 58% rename from src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourcePostRequestObject.cs rename to src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/AttributesInPostRequest.cs index 9447c74668..798ccfd30b 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourcePostRequestObject.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/AttributesInPostRequest.cs @@ -2,7 +2,8 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects { - internal sealed class ResourcePostRequestObject : ResourceObject + // ReSharper disable once UnusedTypeParameter + internal sealed class AttributesInPostRequest where TResource : IIdentifiable { } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourcePatchRequestObject.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/AttributesInResponse.cs similarity index 59% rename from src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourcePatchRequestObject.cs rename to src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/AttributesInResponse.cs index e642d93bbb..65af8f7423 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourcePatchRequestObject.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/AttributesInResponse.cs @@ -2,7 +2,8 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects { - internal sealed class ResourcePatchRequestObject : ResourceObject + // ReSharper disable once UnusedTypeParameter + internal sealed class AttributesInResponse where TResource : IIdentifiable { } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/RelationshipsInPatchRequest.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/RelationshipsInPatchRequest.cs new file mode 100644 index 0000000000..da648ecb05 --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/RelationshipsInPatchRequest.cs @@ -0,0 +1,10 @@ +using JsonApiDotNetCore.Resources; + +namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects +{ + // ReSharper disable once UnusedTypeParameter + internal sealed class RelationshipsInPatchRequest + where TResource : IIdentifiable + { + } +} diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/RelationshipsInPostRequest.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/RelationshipsInPostRequest.cs new file mode 100644 index 0000000000..2ac99e1970 --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/RelationshipsInPostRequest.cs @@ -0,0 +1,10 @@ +using JsonApiDotNetCore.Resources; + +namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects +{ + // ReSharper disable once UnusedTypeParameter + internal sealed class RelationshipsInPostRequest + where TResource : IIdentifiable + { + } +} diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/RelationshipsInResponse.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/RelationshipsInResponse.cs new file mode 100644 index 0000000000..75bff02ac1 --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/RelationshipsInResponse.cs @@ -0,0 +1,10 @@ +using JsonApiDotNetCore.Resources; + +namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects +{ + // ReSharper disable once UnusedTypeParameter + internal sealed class RelationshipsInResponse + where TResource : IIdentifiable + { + } +} diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceIdentifierObject.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceIdentifierObject.cs index ad7fb8bb6c..7471acabd6 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceIdentifierObject.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceIdentifierObject.cs @@ -5,7 +5,7 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects { // ReSharper disable once UnusedTypeParameter - internal class ResourceIdentifierObject : ResourceIdentifierObject + internal sealed class ResourceIdentifierObject : ResourceIdentifierObject where TResource : IIdentifiable { } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceObject.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceObject.cs deleted file mode 100644 index 38218eddc6..0000000000 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceObject.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects -{ - [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal abstract class ResourceObject : ResourceIdentifierObject - where TResource : IIdentifiable - { - public IDictionary Attributes { get; set; } = null!; - - public IDictionary Relationships { get; set; } = null!; - } -} diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceObjectInPatchRequest.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceObjectInPatchRequest.cs new file mode 100644 index 0000000000..dc785579a1 --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceObjectInPatchRequest.cs @@ -0,0 +1,14 @@ +using JetBrains.Annotations; +using JsonApiDotNetCore.Resources; + +namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects +{ + [UsedImplicitly(ImplicitUseTargetFlags.Members)] + internal sealed class ResourceObjectInPatchRequest : ResourceIdentifierObject + where TResource : IIdentifiable + { + public AttributesInPatchRequest Attributes { get; set; } = null!; + + public RelationshipsInPatchRequest Relationships { get; set; } = null!; + } +} diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceObjectInPostRequest.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceObjectInPostRequest.cs new file mode 100644 index 0000000000..873c12d9c4 --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceObjectInPostRequest.cs @@ -0,0 +1,14 @@ +using JetBrains.Annotations; +using JsonApiDotNetCore.Resources; + +namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects +{ + [UsedImplicitly(ImplicitUseTargetFlags.Members)] + internal sealed class ResourceObjectInPostRequest : ResourceIdentifierObject + where TResource : IIdentifiable + { + public AttributesInPostRequest Attributes { get; set; } = null!; + + public RelationshipsInPostRequest Relationships { get; set; } = null!; + } +} diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceResponseObject.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceObjectInResponse.cs similarity index 67% rename from src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceResponseObject.cs rename to src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceObjectInResponse.cs index 62cb0378e5..07e5f42f88 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceResponseObject.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceObjectInResponse.cs @@ -7,9 +7,13 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects { [UsedImplicitly(ImplicitUseTargetFlags.Members)] - internal sealed class ResourceResponseObject : ResourceObject + internal sealed class ResourceObjectInResponse : ResourceIdentifierObject where TResource : IIdentifiable { + public AttributesInResponse Attributes { get; set; } = null!; + + public RelationshipsInResponse Relationships { get; set; } = null!; + [Required] public LinksInResourceObject Links { get; set; } = null!; diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiOperationIdSelector.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiOperationIdSelector.cs index 410a63a4ba..e73c23e822 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiOperationIdSelector.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiOperationIdSelector.cs @@ -6,7 +6,7 @@ using JsonApiDotNetCore.Configuration; using JsonApiDotNetCore.Middleware; using JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; -using JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData; +using JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.Controllers; @@ -32,9 +32,9 @@ internal sealed class JsonApiOperationIdSelector [typeof(ResourceIdentifierCollectionResponseDocument<>)] = RelationshipOperationIdTemplate, [typeof(ResourceIdentifierResponseDocument<>)] = RelationshipOperationIdTemplate, [typeof(NullableResourceIdentifierResponseDocument<>)] = RelationshipOperationIdTemplate, - [typeof(ToOneRelationshipRequestData<>)] = RelationshipOperationIdTemplate, - [typeof(NullableToOneRelationshipRequestData<>)] = RelationshipOperationIdTemplate, - [typeof(ToManyRelationshipRequestData<>)] = RelationshipOperationIdTemplate + [typeof(ToOneRelationshipInRequest<>)] = RelationshipOperationIdTemplate, + [typeof(NullableToOneRelationshipInRequest<>)] = RelationshipOperationIdTemplate, + [typeof(ToManyRelationshipInRequest<>)] = RelationshipOperationIdTemplate }; private readonly IControllerResourceMapping _controllerResourceMapping; diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiRequestFormatMetadataProvider.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiRequestFormatMetadataProvider.cs index e3d2a0a17a..738c90e043 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiRequestFormatMetadataProvider.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiRequestFormatMetadataProvider.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using JsonApiDotNetCore.Middleware; using JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; -using JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData; +using JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.Formatters; using Microsoft.Net.Http.Headers; @@ -15,9 +15,9 @@ internal sealed class JsonApiRequestFormatMetadataProvider : IInputFormatter, IA { private static readonly Type[] JsonApiRequestObjectOpenType = { - typeof(ToManyRelationshipRequestData<>), - typeof(ToOneRelationshipRequestData<>), - typeof(NullableToOneRelationshipRequestData<>), + typeof(ToManyRelationshipInRequest<>), + typeof(ToOneRelationshipInRequest<>), + typeof(NullableToOneRelationshipInRequest<>), typeof(ResourcePostRequestDocument<>), typeof(ResourcePatchRequestDocument<>) }; diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiSchemaIdSelector.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiSchemaIdSelector.cs index d8ad776cf8..a4c9f5575d 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiSchemaIdSelector.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiSchemaIdSelector.cs @@ -4,7 +4,7 @@ using Humanizer; using JsonApiDotNetCore.Configuration; using JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; -using JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData; +using JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships; using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; namespace JsonApiDotNetCore.OpenApi @@ -15,11 +15,15 @@ internal sealed class JsonApiSchemaIdSelector { [typeof(ResourcePostRequestDocument<>)] = "###-post-request-document", [typeof(ResourcePatchRequestDocument<>)] = "###-patch-request-document", - [typeof(ResourcePostRequestObject<>)] = "###-data-in-post-request", - [typeof(ResourcePatchRequestObject<>)] = "###-data-in-patch-request", - [typeof(ToOneRelationshipRequestData<>)] = "to-one-###-request-data", - [typeof(NullableToOneRelationshipRequestData<>)] = "nullable-to-one-###-request-data", - [typeof(ToManyRelationshipRequestData<>)] = "to-many-###-request-data", + [typeof(ResourceObjectInPostRequest<>)] = "###-data-in-post-request", + [typeof(AttributesInPostRequest<>)] = "###-attributes-in-post-request", + [typeof(RelationshipsInPostRequest<>)] = "###-relationships-in-post-request", + [typeof(ResourceObjectInPatchRequest<>)] = "###-data-in-patch-request", + [typeof(AttributesInPatchRequest<>)] = "###-attributes-in-patch-request", + [typeof(RelationshipsInPatchRequest<>)] = "###-relationships-in-patch-request", + [typeof(ToOneRelationshipInRequest<>)] = "to-one-###-in-request", + [typeof(NullableToOneRelationshipInRequest<>)] = "nullable-to-one-###-in-request", + [typeof(ToManyRelationshipInRequest<>)] = "to-many-###-in-request", [typeof(PrimaryResourceResponseDocument<>)] = "###-primary-response-document", [typeof(SecondaryResourceResponseDocument<>)] = "###-secondary-response-document", [typeof(NullableSecondaryResourceResponseDocument<>)] = "nullable-###-secondary-response-document", @@ -27,10 +31,12 @@ internal sealed class JsonApiSchemaIdSelector [typeof(ResourceIdentifierResponseDocument<>)] = "###-identifier-response-document", [typeof(NullableResourceIdentifierResponseDocument<>)] = "nullable-###-identifier-response-document", [typeof(ResourceIdentifierCollectionResponseDocument<>)] = "###-identifier-collection-response-document", - [typeof(ToOneRelationshipResponseData<>)] = "to-one-###-response-data", - [typeof(NullableToOneRelationshipResponseData<>)] = "nullable-to-one-###-response-data", - [typeof(ToManyRelationshipResponseData<>)] = "to-many-###-response-data", - [typeof(ResourceResponseObject<>)] = "###-data-in-response", + [typeof(ToOneRelationshipInResponse<>)] = "to-one-###-in-response", + [typeof(NullableToOneRelationshipInResponse<>)] = "nullable-to-one-###-in-response", + [typeof(ToManyRelationshipInResponse<>)] = "to-many-###-in-response", + [typeof(ResourceObjectInResponse<>)] = "###-data-in-response", + [typeof(AttributesInResponse<>)] = "###-attributes-in-response", + [typeof(RelationshipsInResponse<>)] = "###-relationships-in-response", [typeof(ResourceIdentifierObject<>)] = "###-identifier" }; diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/CachingSwaggerGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/CachingSwaggerGenerator.cs index 07128b71e6..f36f7f9b58 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/CachingSwaggerGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/CachingSwaggerGenerator.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Concurrent; +using System.Collections.Generic; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.Swagger; using Swashbuckle.AspNetCore.SwaggerGen; @@ -26,7 +28,14 @@ public OpenApiDocument GetSwagger(string documentName, string? host = null, stri string cacheKey = $"{documentName}#{host}#{basePath}"; - return _openApiDocumentCache.GetOrAdd(cacheKey, _ => _defaultSwaggerGenerator.GetSwagger(documentName, host, basePath)); + return _openApiDocumentCache.GetOrAdd(cacheKey, _ => + { + OpenApiDocument document = _defaultSwaggerGenerator.GetSwagger(documentName, host, basePath); + + // Remove once https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/2283 is addressed. + document.Components.Schemas = new SortedDictionary(document.Components.Schemas, StringComparer.Ordinal); + return document; + }); } } } diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs index 3e7c98b9f9..7d47d180d5 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs @@ -4,7 +4,7 @@ using JsonApiDotNetCore.Configuration; using JsonApiDotNetCore.OpenApi.JsonApiObjects; using JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; -using JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData; +using JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; @@ -23,9 +23,9 @@ internal sealed class JsonApiSchemaGenerator : ISchemaGenerator typeof(ResourceIdentifierCollectionResponseDocument<>), typeof(ResourceIdentifierResponseDocument<>), typeof(NullableResourceIdentifierResponseDocument<>), - typeof(ToManyRelationshipRequestData<>), - typeof(ToOneRelationshipRequestData<>), - typeof(NullableToOneRelationshipRequestData<>) + typeof(ToManyRelationshipInRequest<>), + typeof(ToOneRelationshipInRequest<>), + typeof(NullableToOneRelationshipInRequest<>) }; private readonly ISchemaGenerator _defaultSchemaGenerator; diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs index bb45460968..620409d5ab 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Reflection; using JsonApiDotNetCore.OpenApi.JsonApiObjects; -using JsonApiDotNetCore.OpenApi.JsonApiObjects.RelationshipData; +using JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships; using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; using JsonApiDotNetCore.Resources.Annotations; using Microsoft.OpenApi.Models; @@ -16,34 +16,31 @@ internal sealed class ResourceFieldObjectSchemaBuilder { private static readonly SchemaRepository ResourceSchemaRepository = new(); - private static readonly Type[] RelationshipResponseDataOpenTypes = + private static readonly Type[] RelationshipInResponseOpenTypes = { - typeof(ToOneRelationshipResponseData<>), - typeof(ToManyRelationshipResponseData<>), - typeof(NullableToOneRelationshipResponseData<>) + typeof(ToOneRelationshipInResponse<>), + typeof(ToManyRelationshipInResponse<>), + typeof(NullableToOneRelationshipInResponse<>) }; private readonly ResourceTypeInfo _resourceTypeInfo; private readonly ISchemaRepositoryAccessor _schemaRepositoryAccessor; private readonly SchemaGenerator _defaultSchemaGenerator; - private readonly JsonApiSchemaIdSelector _jsonApiSchemaIdSelector; private readonly ResourceTypeSchemaGenerator _resourceTypeSchemaGenerator; private readonly NullableReferenceSchemaGenerator _nullableReferenceSchemaGenerator; private readonly IDictionary _schemasForResourceFields; public ResourceFieldObjectSchemaBuilder(ResourceTypeInfo resourceTypeInfo, ISchemaRepositoryAccessor schemaRepositoryAccessor, - SchemaGenerator defaultSchemaGenerator, JsonApiSchemaIdSelector jsonApiSchemaIdSelector, ResourceTypeSchemaGenerator resourceTypeSchemaGenerator) + SchemaGenerator defaultSchemaGenerator, ResourceTypeSchemaGenerator resourceTypeSchemaGenerator) { ArgumentGuard.NotNull(resourceTypeInfo, nameof(resourceTypeInfo)); ArgumentGuard.NotNull(schemaRepositoryAccessor, nameof(schemaRepositoryAccessor)); ArgumentGuard.NotNull(defaultSchemaGenerator, nameof(defaultSchemaGenerator)); - ArgumentGuard.NotNull(jsonApiSchemaIdSelector, nameof(jsonApiSchemaIdSelector)); ArgumentGuard.NotNull(resourceTypeSchemaGenerator, nameof(resourceTypeSchemaGenerator)); _resourceTypeInfo = resourceTypeInfo; _schemaRepositoryAccessor = schemaRepositoryAccessor; _defaultSchemaGenerator = defaultSchemaGenerator; - _jsonApiSchemaIdSelector = jsonApiSchemaIdSelector; _resourceTypeSchemaGenerator = resourceTypeSchemaGenerator; _nullableReferenceSchemaGenerator = new NullableReferenceSchemaGenerator(schemaRepositoryAccessor); @@ -61,25 +58,7 @@ private IDictionary GetFieldSchemas() return fullSchemaForResource.Properties; } - public OpenApiSchema? BuildAttributesObject(OpenApiSchema fullSchemaForResourceObject) - { - ArgumentGuard.NotNull(fullSchemaForResourceObject, nameof(fullSchemaForResourceObject)); - - OpenApiSchema fullSchemaForAttributesObject = fullSchemaForResourceObject.Properties[JsonApiObjectPropertyName.AttributesObject]; - - SetMembersOfAttributesObject(fullSchemaForAttributesObject); - - if (!fullSchemaForAttributesObject.Properties.Any()) - { - return null; - } - - fullSchemaForAttributesObject.AdditionalPropertiesAllowed = false; - - return GetReferenceSchemaForFieldObject(fullSchemaForAttributesObject, JsonApiObjectPropertyName.AttributesObject); - } - - private void SetMembersOfAttributesObject(OpenApiSchema fullSchemaForAttributesObject) + public void SetMembersOfAttributesObject(OpenApiSchema fullSchemaForAttributesObject) { AttrCapabilities requiredCapability = GetRequiredCapabilityForAttributes(_resourceTypeInfo.ResourceObjectOpenType); @@ -103,9 +82,9 @@ private void SetMembersOfAttributesObject(OpenApiSchema fullSchemaForAttributesO private static AttrCapabilities GetRequiredCapabilityForAttributes(Type resourceObjectOpenType) { - return resourceObjectOpenType == typeof(ResourceResponseObject<>) ? AttrCapabilities.AllowView : - resourceObjectOpenType == typeof(ResourcePostRequestObject<>) ? AttrCapabilities.AllowCreate : - resourceObjectOpenType == typeof(ResourcePatchRequestObject<>) ? AttrCapabilities.AllowChange : throw new UnreachableCodeException(); + return resourceObjectOpenType == typeof(ResourceObjectInResponse<>) ? AttrCapabilities.AllowView : + resourceObjectOpenType == typeof(ResourceObjectInPostRequest<>) ? AttrCapabilities.AllowCreate : + resourceObjectOpenType == typeof(ResourceObjectInPatchRequest<>) ? AttrCapabilities.AllowChange : throw new UnreachableCodeException(); } private void AddAttributeSchemaToResourceObject(AttrAttribute attribute, OpenApiSchema attributesObjectSchema, OpenApiSchema resourceAttributeSchema) @@ -127,7 +106,7 @@ private void ExposeSchema(OpenApiReference openApiReference, Type typeRepresente private bool IsFieldRequired(ResourceFieldAttribute field) { - if (field is HasManyAttribute || _resourceTypeInfo.ResourceObjectOpenType != typeof(ResourcePostRequestObject<>)) + if (field is HasManyAttribute || _resourceTypeInfo.ResourceObjectOpenType != typeof(ResourceObjectInPostRequest<>)) { return false; } @@ -144,34 +123,7 @@ private bool IsFieldRequired(ResourceFieldAttribute field) }; } - private OpenApiSchema GetReferenceSchemaForFieldObject(OpenApiSchema fullSchema, string fieldObjectName) - { - // NSwag does not have proper support for using an inline schema for the attributes and relationships object in a resource object, see https://github.com/RicoSuter/NSwag/issues/3474. Once this issue has been resolved, we can remove this. - string resourceObjectSchemaId = _jsonApiSchemaIdSelector.GetSchemaId(_resourceTypeInfo.ResourceObjectType); - string fieldObjectSchemaId = resourceObjectSchemaId.Replace(JsonApiObjectPropertyName.Data, fieldObjectName); - - return _schemaRepositoryAccessor.Current.AddDefinition(fieldObjectSchemaId, fullSchema); - } - - public OpenApiSchema? BuildRelationshipsObject(OpenApiSchema fullSchemaForResourceObject) - { - ArgumentGuard.NotNull(fullSchemaForResourceObject, nameof(fullSchemaForResourceObject)); - - OpenApiSchema fullSchemaForRelationshipsObject = fullSchemaForResourceObject.Properties[JsonApiObjectPropertyName.RelationshipsObject]; - - SetMembersOfRelationshipsObject(fullSchemaForRelationshipsObject); - - if (!fullSchemaForRelationshipsObject.Properties.Any()) - { - return null; - } - - fullSchemaForRelationshipsObject.AdditionalPropertiesAllowed = false; - - return GetReferenceSchemaForFieldObject(fullSchemaForRelationshipsObject, JsonApiObjectPropertyName.RelationshipsObject); - } - - private void SetMembersOfRelationshipsObject(OpenApiSchema fullSchemaForRelationshipsObject) + public void SetMembersOfRelationshipsObject(OpenApiSchema fullSchemaForRelationshipsObject) { foreach (string fieldName in _schemasForResourceFields.Keys) { @@ -180,7 +132,7 @@ private void SetMembersOfRelationshipsObject(OpenApiSchema fullSchemaForRelation if (matchingRelationship != null) { EnsureResourceIdentifierObjectSchemaExists(matchingRelationship); - AddRelationshipDataSchemaToResourceObject(matchingRelationship, fullSchemaForRelationshipsObject); + AddRelationshipSchemaToResourceObject(matchingRelationship, fullSchemaForRelationshipsObject); } } } @@ -212,49 +164,46 @@ private void GenerateResourceIdentifierObjectSchema(Type resourceIdentifierObjec fullSchemaForResourceIdentifierObject.Properties[JsonApiObjectPropertyName.Type] = _resourceTypeSchemaGenerator.Get(resourceType); } - private void AddRelationshipDataSchemaToResourceObject(RelationshipAttribute relationship, OpenApiSchema fullSchemaForRelationshipObject) + private void AddRelationshipSchemaToResourceObject(RelationshipAttribute relationship, OpenApiSchema fullSchemaForRelationshipsObject) { - Type relationshipDataType = GetRelationshipDataType(relationship, _resourceTypeInfo.ResourceObjectOpenType); + Type relationshipSchemaType = GetRelationshipSchemaType(relationship, _resourceTypeInfo.ResourceObjectOpenType); - OpenApiSchema relationshipDataSchema = GetReferenceSchemaForRelationshipData(relationshipDataType) ?? - CreateRelationshipDataObjectSchema(relationshipDataType); + OpenApiSchema relationshipSchema = GetReferenceSchemaForRelationship(relationshipSchemaType) ?? CreateRelationshipSchema(relationshipSchemaType); - fullSchemaForRelationshipObject.Properties.Add(relationship.PublicName, relationshipDataSchema); + fullSchemaForRelationshipsObject.Properties.Add(relationship.PublicName, relationshipSchema); if (IsFieldRequired(relationship)) { - fullSchemaForRelationshipObject.Required.Add(relationship.PublicName); + fullSchemaForRelationshipsObject.Required.Add(relationship.PublicName); } } - private static Type GetRelationshipDataType(RelationshipAttribute relationship, Type resourceObjectType) + private static Type GetRelationshipSchemaType(RelationshipAttribute relationship, Type resourceObjectType) { - return resourceObjectType.GetGenericTypeDefinition().IsAssignableTo(typeof(ResourceResponseObject<>)) - ? RelationshipDataTypeFactory.Instance.GetForResponse(relationship) - : RelationshipDataTypeFactory.Instance.GetForRequest(relationship); + return resourceObjectType.GetGenericTypeDefinition().IsAssignableTo(typeof(ResourceObjectInResponse<>)) + ? RelationshipTypeFactory.Instance.GetForResponse(relationship) + : RelationshipTypeFactory.Instance.GetForRequest(relationship); } - private OpenApiSchema? GetReferenceSchemaForRelationshipData(Type relationshipDataType) + private OpenApiSchema? GetReferenceSchemaForRelationship(Type relationshipSchemaType) { - _schemaRepositoryAccessor.Current.TryLookupByType(relationshipDataType, out OpenApiSchema? referenceSchemaForRelationshipData); - return referenceSchemaForRelationshipData; + _schemaRepositoryAccessor.Current.TryLookupByType(relationshipSchemaType, out OpenApiSchema? referenceSchema); + return referenceSchema; } - private OpenApiSchema CreateRelationshipDataObjectSchema(Type relationshipDataType) + private OpenApiSchema CreateRelationshipSchema(Type relationshipSchemaType) { - OpenApiSchema referenceSchema = _defaultSchemaGenerator.GenerateSchema(relationshipDataType, _schemaRepositoryAccessor.Current); + OpenApiSchema referenceSchema = _defaultSchemaGenerator.GenerateSchema(relationshipSchemaType, _schemaRepositoryAccessor.Current); OpenApiSchema fullSchema = _schemaRepositoryAccessor.Current.Schemas[referenceSchema.Reference.Id]; - if (IsDataPropertyNullable(relationshipDataType)) + if (IsDataPropertyNullable(relationshipSchemaType)) { fullSchema.Properties[JsonApiObjectPropertyName.Data] = _nullableReferenceSchemaGenerator.GenerateSchema(fullSchema.Properties[JsonApiObjectPropertyName.Data]); } - Type relationshipDataOpenType = relationshipDataType.GetGenericTypeDefinition(); - - if (IsRelationshipDataPropertyInResponse(relationshipDataOpenType)) + if (IsRelationshipInResponseType(relationshipSchemaType)) { fullSchema.Required.Remove(JsonApiObjectPropertyName.Data); } @@ -262,9 +211,11 @@ private OpenApiSchema CreateRelationshipDataObjectSchema(Type relationshipDataTy return referenceSchema; } - private static bool IsRelationshipDataPropertyInResponse(Type relationshipDataOpenType) + private static bool IsRelationshipInResponseType(Type relationshipSchemaType) { - return RelationshipResponseDataOpenTypes.Contains(relationshipDataOpenType); + Type relationshipSchemaOpenType = relationshipSchemaType.GetGenericTypeDefinition(); + + return RelationshipInResponseOpenTypes.Contains(relationshipSchemaOpenType); } private static bool IsDataPropertyNullable(Type type) diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs index e374b203b7..1db417f7e5 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Text.Json; +using System.Linq; using JsonApiDotNetCore.Configuration; using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; using Microsoft.OpenApi.Models; @@ -15,7 +15,7 @@ internal sealed class ResourceObjectSchemaGenerator private readonly ISchemaRepositoryAccessor _schemaRepositoryAccessor; private readonly ResourceTypeSchemaGenerator _resourceTypeSchemaGenerator; private readonly bool _allowClientGeneratedIds; - private readonly Func _createFieldObjectBuilderFactory; + private readonly Func _resourceFieldObjectSchemaBuilderFactory; public ResourceObjectSchemaGenerator(SchemaGenerator defaultSchemaGenerator, IResourceGraph resourceGraph, IJsonApiOptions options, ISchemaRepositoryAccessor schemaRepositoryAccessor) @@ -32,20 +32,8 @@ public ResourceObjectSchemaGenerator(SchemaGenerator defaultSchemaGenerator, IRe _resourceTypeSchemaGenerator = new ResourceTypeSchemaGenerator(schemaRepositoryAccessor, resourceGraph); _allowClientGeneratedIds = options.AllowClientGeneratedIds; - _createFieldObjectBuilderFactory = CreateFieldObjectBuilderFactory(defaultSchemaGenerator, resourceGraph, options, schemaRepositoryAccessor, - _resourceTypeSchemaGenerator); - } - - private static Func CreateFieldObjectBuilderFactory(SchemaGenerator defaultSchemaGenerator, - IResourceGraph resourceGraph, IJsonApiOptions options, ISchemaRepositoryAccessor schemaRepositoryAccessor, - ResourceTypeSchemaGenerator resourceTypeSchemaGenerator) - { - JsonNamingPolicy? namingPolicy = options.SerializerOptions.PropertyNamingPolicy; - ResourceNameFormatter resourceNameFormatter = new(namingPolicy); - var jsonApiSchemaIdSelector = new JsonApiSchemaIdSelector(resourceNameFormatter, resourceGraph); - - return resourceTypeInfo => new ResourceFieldObjectSchemaBuilder(resourceTypeInfo, schemaRepositoryAccessor, defaultSchemaGenerator, - jsonApiSchemaIdSelector, resourceTypeSchemaGenerator); + _resourceFieldObjectSchemaBuilderFactory = resourceTypeInfo => new ResourceFieldObjectSchemaBuilder(resourceTypeInfo, schemaRepositoryAccessor, + defaultSchemaGenerator, _resourceTypeSchemaGenerator); } public OpenApiSchema GenerateSchema(Type resourceObjectType) @@ -55,7 +43,7 @@ public OpenApiSchema GenerateSchema(Type resourceObjectType) (OpenApiSchema fullSchemaForResourceObject, OpenApiSchema referenceSchemaForResourceObject) = EnsureSchemasExist(resourceObjectType); var resourceTypeInfo = ResourceTypeInfo.Create(resourceObjectType, _resourceGraph); - ResourceFieldObjectSchemaBuilder fieldObjectBuilder = _createFieldObjectBuilderFactory(resourceTypeInfo); + ResourceFieldObjectSchemaBuilder fieldObjectBuilder = _resourceFieldObjectSchemaBuilderFactory(resourceTypeInfo); RemoveResourceIdIfPostResourceObject(resourceTypeInfo.ResourceObjectOpenType, fullSchemaForResourceObject); @@ -92,7 +80,7 @@ public OpenApiSchema GenerateSchema(Type resourceObjectType) private void RemoveResourceIdIfPostResourceObject(Type resourceObjectOpenType, OpenApiSchema fullSchemaForResourceObject) { - if (resourceObjectOpenType == typeof(ResourcePostRequestObject<>) && !_allowClientGeneratedIds) + if (resourceObjectOpenType == typeof(ResourceObjectInPostRequest<>) && !_allowClientGeneratedIds) { fullSchemaForResourceObject.Required.Remove(JsonApiObjectPropertyName.Id); fullSchemaForResourceObject.Properties.Remove(JsonApiObjectPropertyName.Id); @@ -104,31 +92,39 @@ private void SetResourceType(OpenApiSchema fullSchemaForResourceObject, Type res fullSchemaForResourceObject.Properties[JsonApiObjectPropertyName.Type] = _resourceTypeSchemaGenerator.Get(resourceType); } - private static void SetResourceAttributes(OpenApiSchema fullSchemaForResourceObject, ResourceFieldObjectSchemaBuilder builder) + private void SetResourceAttributes(OpenApiSchema fullSchemaForResourceObject, ResourceFieldObjectSchemaBuilder builder) { - OpenApiSchema? fullSchemaForAttributesObject = builder.BuildAttributesObject(fullSchemaForResourceObject); + OpenApiSchema referenceSchemaForAttributesObject = fullSchemaForResourceObject.Properties[JsonApiObjectPropertyName.AttributesObject]; + OpenApiSchema fullSchemaForAttributesObject = _schemaRepositoryAccessor.Current.Schemas[referenceSchemaForAttributesObject.Reference.Id]; + + builder.SetMembersOfAttributesObject(fullSchemaForAttributesObject); - if (fullSchemaForAttributesObject != null) + if (!fullSchemaForAttributesObject.Properties.Any()) { - fullSchemaForResourceObject.Properties[JsonApiObjectPropertyName.AttributesObject] = fullSchemaForAttributesObject; + fullSchemaForResourceObject.Properties.Remove(JsonApiObjectPropertyName.AttributesObject); + _schemaRepositoryAccessor.Current.Schemas.Remove(referenceSchemaForAttributesObject.Reference.Id); } else { - fullSchemaForResourceObject.Properties.Remove(JsonApiObjectPropertyName.AttributesObject); + fullSchemaForAttributesObject.AdditionalPropertiesAllowed = false; } } - private static void SetResourceRelationships(OpenApiSchema fullSchemaForResourceObject, ResourceFieldObjectSchemaBuilder builder) + private void SetResourceRelationships(OpenApiSchema fullSchemaForResourceObject, ResourceFieldObjectSchemaBuilder builder) { - OpenApiSchema? fullSchemaForRelationshipsObject = builder.BuildRelationshipsObject(fullSchemaForResourceObject); + OpenApiSchema referenceSchemaForRelationshipsObject = fullSchemaForResourceObject.Properties[JsonApiObjectPropertyName.RelationshipsObject]; + OpenApiSchema fullSchemaForRelationshipsObject = _schemaRepositoryAccessor.Current.Schemas[referenceSchemaForRelationshipsObject.Reference.Id]; + + builder.SetMembersOfRelationshipsObject(fullSchemaForRelationshipsObject); - if (fullSchemaForRelationshipsObject != null) + if (!fullSchemaForRelationshipsObject.Properties.Any()) { - fullSchemaForResourceObject.Properties[JsonApiObjectPropertyName.RelationshipsObject] = fullSchemaForRelationshipsObject; + fullSchemaForResourceObject.Properties.Remove(JsonApiObjectPropertyName.RelationshipsObject); + _schemaRepositoryAccessor.Current.Schemas.Remove(referenceSchemaForRelationshipsObject.Reference.Id); } else { - fullSchemaForResourceObject.Properties.Remove(JsonApiObjectPropertyName.RelationshipsObject); + fullSchemaForRelationshipsObject.AdditionalPropertiesAllowed = false; } } diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeInfo.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeInfo.cs index ff7cc34d5e..4bef12a5bb 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeInfo.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeInfo.cs @@ -5,13 +5,11 @@ namespace JsonApiDotNetCore.OpenApi.SwaggerComponents { internal sealed class ResourceTypeInfo { - public Type ResourceObjectType { get; } public Type ResourceObjectOpenType { get; } public ResourceType ResourceType { get; } - private ResourceTypeInfo(Type resourceObjectType, Type resourceObjectOpenType, ResourceType resourceType) + private ResourceTypeInfo(Type resourceObjectOpenType, ResourceType resourceType) { - ResourceObjectType = resourceObjectType; ResourceObjectOpenType = resourceObjectOpenType; ResourceType = resourceType; } @@ -25,7 +23,7 @@ public static ResourceTypeInfo Create(Type resourceObjectType, IResourceGraph re Type resourceClrType = resourceObjectType.GenericTypeArguments[0]; ResourceType resourceType = resourceGraph.GetResourceType(resourceClrType); - return new ResourceTypeInfo(resourceObjectType, resourceObjectOpenType, resourceType); + return new ResourceTypeInfo(resourceObjectOpenType, resourceType); } } } diff --git a/test/OpenApiClientTests/LegacyClient/RequestTests.cs b/test/OpenApiClientTests/LegacyClient/RequestTests.cs index 4f4ddce61b..f5a0244525 100644 --- a/test/OpenApiClientTests/LegacyClient/RequestTests.cs +++ b/test/OpenApiClientTests/LegacyClient/RequestTests.cs @@ -69,7 +69,7 @@ public async Task Partial_posting_resource_with_selected_relationships_produces_ Type = FlightsResourceType.Flights, Relationships = new FlightRelationshipsInPostRequest { - Purser = new ToOneFlightAttendantRequestData + Purser = new ToOneFlightAttendantInRequest { Data = new FlightAttendantIdentifier { @@ -77,7 +77,7 @@ public async Task Partial_posting_resource_with_selected_relationships_produces_ Type = FlightAttendantsResourceType.FlightAttendants } }, - BackupPurser = new NullableToOneFlightAttendantRequestData + BackupPurser = new NullableToOneFlightAttendantInRequest { Data = new FlightAttendantIdentifier { @@ -325,7 +325,7 @@ public async Task Patching_ToOne_relationship_produces_expected_request() using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); - var requestDocument = new ToOneFlightAttendantRequestData + var requestDocument = new ToOneFlightAttendantInRequest { Data = new FlightAttendantIdentifier { @@ -382,7 +382,7 @@ public async Task Posting_ToMany_relationship_produces_expected_request() using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); - var requestDocument = new ToManyFlightAttendantRequestData + var requestDocument = new ToManyFlightAttendantInRequest { Data = new List { @@ -433,7 +433,7 @@ public async Task Patching_ToMany_relationship_produces_expected_request() using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); - var requestDocument = new ToManyFlightAttendantRequestData + var requestDocument = new ToManyFlightAttendantInRequest { Data = new List { @@ -484,7 +484,7 @@ public async Task Deleting_ToMany_relationship_produces_expected_request() using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); - var requestDocument = new ToManyFlightAttendantRequestData + var requestDocument = new ToManyFlightAttendantInRequest { Data = new List { diff --git a/test/OpenApiClientTests/LegacyClient/ResponseTests.cs b/test/OpenApiClientTests/LegacyClient/ResponseTests.cs index 5a823219aa..1b6b00faf6 100644 --- a/test/OpenApiClientTests/LegacyClient/ResponseTests.cs +++ b/test/OpenApiClientTests/LegacyClient/ResponseTests.cs @@ -283,7 +283,7 @@ public async Task Posting_resource_translates_response() Type = FlightsResourceType.Flights, Relationships = new FlightRelationshipsInPostRequest { - Purser = new ToOneFlightAttendantRequestData + Purser = new ToOneFlightAttendantInRequest { Data = new FlightAttendantIdentifier { @@ -552,7 +552,7 @@ public async Task Patching_ToOne_relationship_translates_response() IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); // Act - await apiClient.PatchFlightPurserRelationshipAsync("ZvuH1", new ToOneFlightAttendantRequestData + await apiClient.PatchFlightPurserRelationshipAsync("ZvuH1", new ToOneFlightAttendantInRequest { Data = new FlightAttendantIdentifier { @@ -608,7 +608,7 @@ public async Task Posting_ToMany_relationship_produces_empty_response() IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); // Act - Func action = async () => await apiClient.PostFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantRequestData + Func action = async () => await apiClient.PostFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantInRequest { Data = new List { @@ -637,7 +637,7 @@ public async Task Patching_ToMany_relationship_produces_empty_response() IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); // Act - Func action = async () => await apiClient.PatchFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantRequestData + Func action = async () => await apiClient.PatchFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantInRequest { Data = new List { @@ -666,7 +666,7 @@ public async Task Deleting_ToMany_relationship_produces_empty_response() IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); // Act - Func action = async () => await apiClient.DeleteFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantRequestData + Func action = async () => await apiClient.DeleteFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantInRequest { Data = new List { diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json b/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json index 00d523bfe8..ac62204a53 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json +++ b/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json @@ -326,7 +326,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } } } @@ -356,7 +356,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } } } @@ -386,7 +386,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } } } @@ -719,7 +719,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } } } @@ -749,7 +749,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } } } @@ -779,7 +779,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } } } @@ -925,7 +925,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } } } @@ -955,7 +955,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } } } @@ -985,7 +985,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } } } @@ -1318,7 +1318,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/nullable-to-one-flight-attendant-request-data" + "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" } } } @@ -1464,7 +1464,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-attendant-request-data" + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" } } } @@ -1494,7 +1494,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-attendant-request-data" + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" } } } @@ -1524,7 +1524,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-attendant-request-data" + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" } } } @@ -1670,7 +1670,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-passenger-request-data" + "$ref": "#/components/schemas/to-many-passenger-in-request" } } } @@ -1700,7 +1700,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-passenger-request-data" + "$ref": "#/components/schemas/to-many-passenger-in-request" } } } @@ -1730,7 +1730,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-passenger-request-data" + "$ref": "#/components/schemas/to-many-passenger-in-request" } } } @@ -1876,7 +1876,7 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-one-flight-attendant-request-data" + "$ref": "#/components/schemas/to-one-flight-attendant-in-request" } } } @@ -2156,7 +2156,7 @@ "type": "object", "properties": { "flights": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } }, "additionalProperties": false @@ -2165,7 +2165,7 @@ "type": "object", "properties": { "flights": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } }, "additionalProperties": false @@ -2174,7 +2174,7 @@ "type": "object", "properties": { "flights": { - "$ref": "#/components/schemas/to-many-flight-response-data" + "$ref": "#/components/schemas/to-many-flight-in-response" } }, "additionalProperties": false @@ -2469,10 +2469,10 @@ "type": "object", "properties": { "scheduled-for-flights": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" }, "purser-on-flights": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } }, "additionalProperties": false @@ -2481,10 +2481,10 @@ "type": "object", "properties": { "scheduled-for-flights": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" }, "purser-on-flights": { - "$ref": "#/components/schemas/to-many-flight-request-data" + "$ref": "#/components/schemas/to-many-flight-in-request" } }, "additionalProperties": false @@ -2493,10 +2493,10 @@ "type": "object", "properties": { "scheduled-for-flights": { - "$ref": "#/components/schemas/to-many-flight-response-data" + "$ref": "#/components/schemas/to-many-flight-in-response" }, "purser-on-flights": { - "$ref": "#/components/schemas/to-many-flight-response-data" + "$ref": "#/components/schemas/to-many-flight-in-response" } }, "additionalProperties": false @@ -2768,16 +2768,16 @@ "type": "object", "properties": { "cabin-crew-members": { - "$ref": "#/components/schemas/to-many-flight-attendant-request-data" + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" }, "purser": { - "$ref": "#/components/schemas/to-one-flight-attendant-request-data" + "$ref": "#/components/schemas/to-one-flight-attendant-in-request" }, "backup-purser": { - "$ref": "#/components/schemas/nullable-to-one-flight-attendant-request-data" + "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" }, "passengers": { - "$ref": "#/components/schemas/to-many-passenger-request-data" + "$ref": "#/components/schemas/to-many-passenger-in-request" } }, "additionalProperties": false @@ -2789,16 +2789,16 @@ "type": "object", "properties": { "cabin-crew-members": { - "$ref": "#/components/schemas/to-many-flight-attendant-request-data" + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" }, "purser": { - "$ref": "#/components/schemas/to-one-flight-attendant-request-data" + "$ref": "#/components/schemas/to-one-flight-attendant-in-request" }, "backup-purser": { - "$ref": "#/components/schemas/nullable-to-one-flight-attendant-request-data" + "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" }, "passengers": { - "$ref": "#/components/schemas/to-many-passenger-request-data" + "$ref": "#/components/schemas/to-many-passenger-in-request" } }, "additionalProperties": false @@ -2807,16 +2807,16 @@ "type": "object", "properties": { "cabin-crew-members": { - "$ref": "#/components/schemas/to-many-flight-attendant-response-data" + "$ref": "#/components/schemas/to-many-flight-attendant-in-response" }, "purser": { - "$ref": "#/components/schemas/to-one-flight-attendant-response-data" + "$ref": "#/components/schemas/to-one-flight-attendant-in-response" }, "backup-purser": { - "$ref": "#/components/schemas/nullable-to-one-flight-attendant-response-data" + "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-response" }, "passengers": { - "$ref": "#/components/schemas/to-many-passenger-response-data" + "$ref": "#/components/schemas/to-many-passenger-in-response" } }, "additionalProperties": false @@ -3057,7 +3057,7 @@ }, "additionalProperties": false }, - "nullable-to-one-flight-attendant-request-data": { + "nullable-to-one-flight-attendant-in-request": { "required": [ "data" ], @@ -3076,7 +3076,7 @@ }, "additionalProperties": false }, - "nullable-to-one-flight-attendant-response-data": { + "nullable-to-one-flight-attendant-in-response": { "required": [ "links" ], @@ -3216,7 +3216,7 @@ ], "type": "string" }, - "to-many-flight-attendant-request-data": { + "to-many-flight-attendant-in-request": { "required": [ "data" ], @@ -3231,7 +3231,7 @@ }, "additionalProperties": false }, - "to-many-flight-attendant-response-data": { + "to-many-flight-attendant-in-response": { "required": [ "links" ], @@ -3253,7 +3253,7 @@ }, "additionalProperties": false }, - "to-many-flight-request-data": { + "to-many-flight-in-request": { "required": [ "data" ], @@ -3268,7 +3268,7 @@ }, "additionalProperties": false }, - "to-many-flight-response-data": { + "to-many-flight-in-response": { "required": [ "links" ], @@ -3290,7 +3290,7 @@ }, "additionalProperties": false }, - "to-many-passenger-request-data": { + "to-many-passenger-in-request": { "required": [ "data" ], @@ -3305,7 +3305,7 @@ }, "additionalProperties": false }, - "to-many-passenger-response-data": { + "to-many-passenger-in-response": { "required": [ "links" ], @@ -3327,7 +3327,7 @@ }, "additionalProperties": false }, - "to-one-flight-attendant-request-data": { + "to-one-flight-attendant-in-request": { "required": [ "data" ], @@ -3339,7 +3339,7 @@ }, "additionalProperties": false }, - "to-one-flight-attendant-response-data": { + "to-one-flight-attendant-in-response": { "required": [ "links" ],