From 41602a71be93e1dc866dd1de79f8de18015a6782 Mon Sep 17 00:00:00 2001 From: Maurits Moeys Date: Fri, 6 Jan 2023 16:23:01 +0100 Subject: [PATCH 1/2] Switch to built-in support for nullable reference schemas --- .../OpenApiSchemaExtensions.cs | 18 + .../ServiceCollectionExtensions.cs | 1 + .../JsonApiSchemaGenerator.cs | 26 +- .../NullableReferenceSchemaGenerator.cs | 103 --- .../NullableReferenceSchemaStrategy.cs | 7 - .../ResourceFieldObjectSchemaBuilder.cs | 62 +- .../ResourceObjectSchemaGenerator.cs | 10 +- .../ResourceTypeSchemaGenerator.cs | 20 +- .../LegacyClient/swagger.g.json | 829 ++++++++++++++---- .../CamelCase/swagger.g.json | 409 ++++++--- .../KebabCase/swagger.g.json | 409 ++++++--- .../PascalCase/swagger.g.json | 409 ++++++--- .../ModelStateValidationOff/swagger.g.json | 331 +++++-- .../ModelStateValidationOn/swagger.g.json | 373 ++++++-- .../ModelStateValidationOff/swagger.g.json | 421 ++++++--- .../ModelStateValidationOn/swagger.g.json | 421 ++++++--- .../LegacyOpenApiIntegration/swagger.json | 829 ++++++++++++++---- .../CamelCase/CamelCaseTests.cs | 70 +- .../KebabCase/KebabCaseTests.cs | 74 +- .../PascalCase/PascalCaseTests.cs | 70 +- test/OpenApiTests/OpenApiTests.csproj | 3 +- .../NullabilityTests.cs | 14 +- .../NullabilityTests.cs | 14 +- .../NullabilityTests.cs | 14 +- .../NullabilityTests.cs | 14 +- 25 files changed, 3641 insertions(+), 1310 deletions(-) create mode 100644 src/JsonApiDotNetCore.OpenApi/OpenApiSchemaExtensions.cs delete mode 100644 src/JsonApiDotNetCore.OpenApi/SwaggerComponents/NullableReferenceSchemaGenerator.cs delete mode 100644 src/JsonApiDotNetCore.OpenApi/SwaggerComponents/NullableReferenceSchemaStrategy.cs diff --git a/src/JsonApiDotNetCore.OpenApi/OpenApiSchemaExtensions.cs b/src/JsonApiDotNetCore.OpenApi/OpenApiSchemaExtensions.cs new file mode 100644 index 0000000000..e86c2c7423 --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi/OpenApiSchemaExtensions.cs @@ -0,0 +1,18 @@ +using Microsoft.OpenApi.Models; + +namespace JsonApiDotNetCore.OpenApi; + +internal static class OpenApiSchemaExtensions +{ + public static OpenApiSchema UnwrapExtendedReferenceSchema(this OpenApiSchema source) + { + ArgumentGuard.NotNull(source); + + if (source.AllOf.Count != 1) + { + throw new InvalidOperationException($"Schema '{nameof(source)}' should not contain multiple entries in '{nameof(source.AllOf)}' "); + } + + return source.AllOf.Single(); + } +} diff --git a/src/JsonApiDotNetCore.OpenApi/ServiceCollectionExtensions.cs b/src/JsonApiDotNetCore.OpenApi/ServiceCollectionExtensions.cs index 2cec6680e2..7f54d776f4 100644 --- a/src/JsonApiDotNetCore.OpenApi/ServiceCollectionExtensions.cs +++ b/src/JsonApiDotNetCore.OpenApi/ServiceCollectionExtensions.cs @@ -70,6 +70,7 @@ private static void AddSwaggerGenerator(IServiceScope scope, IServiceCollection SetOperationInfo(swaggerGenOptions, controllerResourceMapping, namingPolicy); SetSchemaIdSelector(swaggerGenOptions, resourceGraph, namingPolicy); swaggerGenOptions.DocumentFilter(); + swaggerGenOptions.UseAllOfToExtendReferenceSchemas(); swaggerGenOptions.OperationFilter(); setupSwaggerGenAction?.Invoke(swaggerGenOptions); diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs index 3c08df30db..0a3b3c01b5 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs @@ -47,7 +47,6 @@ internal sealed class JsonApiSchemaGenerator : ISchemaGenerator private readonly ISchemaGenerator _defaultSchemaGenerator; private readonly IJsonApiOptions _options; private readonly ResourceObjectSchemaGenerator _resourceObjectSchemaGenerator; - private readonly NullableReferenceSchemaGenerator _nullableReferenceSchemaGenerator; private readonly SchemaRepositoryAccessor _schemaRepositoryAccessor = new(); public JsonApiSchemaGenerator(SchemaGenerator defaultSchemaGenerator, IResourceGraph resourceGraph, IJsonApiOptions options, @@ -60,7 +59,6 @@ public JsonApiSchemaGenerator(SchemaGenerator defaultSchemaGenerator, IResourceG _defaultSchemaGenerator = defaultSchemaGenerator; _options = options; - _nullableReferenceSchemaGenerator = new NullableReferenceSchemaGenerator(_schemaRepositoryAccessor, options.SerializerOptions.PropertyNamingPolicy); _resourceObjectSchemaGenerator = new ResourceObjectSchemaGenerator(defaultSchemaGenerator, resourceGraph, options, _schemaRepositoryAccessor, resourceFieldValidationMetadataProvider); @@ -76,7 +74,11 @@ public OpenApiSchema GenerateSchema(Type modelType, SchemaRepository schemaRepos if (schemaRepository.TryLookupByType(modelType, out OpenApiSchema jsonApiDocumentSchema)) { - return jsonApiDocumentSchema; + // For unknown reasons, Swashbuckle chooses to wrap root request bodies, but not response bodies. + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/861#issuecomment-1373631712 + return memberInfo != null || parameterInfo != null + ? _defaultSchemaGenerator.GenerateSchema(modelType, schemaRepository, memberInfo, parameterInfo) + : jsonApiDocumentSchema; } if (IsJsonApiDocument(modelType)) @@ -92,6 +94,8 @@ public OpenApiSchema GenerateSchema(Type modelType, SchemaRepository schemaRepos { RemoveJsonApiObject(schema); } + + // Schema might depend on other schemas not handled by us, so should not return here. } return _defaultSchemaGenerator.GenerateSchema(modelType, schemaRepository, memberInfo, parameterInfo, routeInfo); @@ -116,7 +120,7 @@ private OpenApiSchema GenerateJsonApiDocumentSchema(Type documentType) OpenApiSchema referenceSchemaForDataObject = IsManyDataDocument(documentType) ? CreateArrayTypeDataSchema(referenceSchemaForResourceObject) - : referenceSchemaForResourceObject; + : CreateExtendedReferenceSchema(referenceSchemaForResourceObject); fullSchemaForDocument.Properties[JsonApiPropertyName.Data] = referenceSchemaForDataObject; @@ -150,7 +154,8 @@ private void SetDataObjectSchemaToNullable(OpenApiSchema referenceSchemaForDocum { OpenApiSchema fullSchemaForDocument = _schemaRepositoryAccessor.Current.Schemas[referenceSchemaForDocument.Reference.Id]; OpenApiSchema referenceSchemaForData = fullSchemaForDocument.Properties[JsonApiPropertyName.Data]; - fullSchemaForDocument.Properties[JsonApiPropertyName.Data] = _nullableReferenceSchemaGenerator.GenerateSchema(referenceSchemaForData); + referenceSchemaForData.Nullable = true; + fullSchemaForDocument.Properties[JsonApiPropertyName.Data] = referenceSchemaForData; } private void RemoveJsonApiObject(OpenApiSchema referenceSchemaForDocument) @@ -160,4 +165,15 @@ private void RemoveJsonApiObject(OpenApiSchema referenceSchemaForDocument) _schemaRepositoryAccessor.Current.Schemas.Remove("jsonapi-object"); } + + private static OpenApiSchema CreateExtendedReferenceSchema(OpenApiSchema referenceSchemaForResourceObject) + { + return new OpenApiSchema + { + AllOf = new List + { + referenceSchemaForResourceObject + } + }; + } } diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/NullableReferenceSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/NullableReferenceSchemaGenerator.cs deleted file mode 100644 index f40bb0c60a..0000000000 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/NullableReferenceSchemaGenerator.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System.Text.Json; -using Microsoft.OpenApi.Models; - -namespace JsonApiDotNetCore.OpenApi.SwaggerComponents; - -internal sealed class NullableReferenceSchemaGenerator -{ - private const string PascalCaseNullableSchemaReferenceId = "NullValue"; - - private readonly NullableReferenceSchemaStrategy _nullableReferenceStrategy = - Enum.Parse(NullableReferenceSchemaStrategy.Implicit.ToString()); - - private readonly ISchemaRepositoryAccessor _schemaRepositoryAccessor; - private readonly string _nullableSchemaReferenceId; - - private OpenApiSchema? _referenceSchemaForExplicitNullValue; - - public NullableReferenceSchemaGenerator(ISchemaRepositoryAccessor schemaRepositoryAccessor, JsonNamingPolicy? namingPolicy) - { - ArgumentGuard.NotNull(schemaRepositoryAccessor); - - _schemaRepositoryAccessor = schemaRepositoryAccessor; - _nullableSchemaReferenceId = namingPolicy != null ? namingPolicy.ConvertName(PascalCaseNullableSchemaReferenceId) : PascalCaseNullableSchemaReferenceId; - } - - public OpenApiSchema GenerateSchema(OpenApiSchema referenceSchema) - { - ArgumentGuard.NotNull(referenceSchema); - - return new OpenApiSchema - { - OneOf = new List - { - referenceSchema, - _nullableReferenceStrategy == NullableReferenceSchemaStrategy.Explicit ? GetExplicitNullSchema() : GetImplicitNullSchema() - } - }; - } - - // This approach is supported in OAS starting from v3.1. See https://github.com/OAI/OpenAPI-Specification/issues/1368#issuecomment-580103688 - private static OpenApiSchema GetExplicitNullSchema() - { - return new OpenApiSchema - { - Type = "null" - }; - } - - // This approach is supported starting from OAS v3.0. See https://github.com/OAI/OpenAPI-Specification/issues/1368#issuecomment-487314681 - private OpenApiSchema GetImplicitNullSchema() - { - EnsureFullSchemaForNullValueExists(); - - return _referenceSchemaForExplicitNullValue ??= new OpenApiSchema - { - Reference = new OpenApiReference - { - Id = _nullableSchemaReferenceId, - Type = ReferenceType.Schema - } - }; - } - - private void EnsureFullSchemaForNullValueExists() - { - if (!_schemaRepositoryAccessor.Current.Schemas.ContainsKey(_nullableSchemaReferenceId)) - { - var fullSchemaForNullValue = new OpenApiSchema - { - Nullable = true, - Not = new OpenApiSchema - { - AnyOf = new List - { - new() - { - Type = "string" - }, - new() - { - Type = "number" - }, - new() - { - Type = "boolean" - }, - new() - { - Type = "object" - }, - new() - { - Type = "array" - } - }, - Items = new OpenApiSchema() - } - }; - - _schemaRepositoryAccessor.Current.AddDefinition(_nullableSchemaReferenceId, fullSchemaForNullValue); - } - } -} diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/NullableReferenceSchemaStrategy.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/NullableReferenceSchemaStrategy.cs deleted file mode 100644 index 282b4a282b..0000000000 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/NullableReferenceSchemaStrategy.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace JsonApiDotNetCore.OpenApi.SwaggerComponents; - -internal enum NullableReferenceSchemaStrategy -{ - Implicit, - Explicit -} diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs index a3691f3b58..881638c370 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs @@ -1,4 +1,4 @@ -using System.Text.Json; +using System.Reflection; using JsonApiDotNetCore.OpenApi.JsonApiMetadata; using JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships; using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; @@ -35,14 +35,14 @@ internal sealed class ResourceFieldObjectSchemaBuilder private readonly SchemaGenerator _defaultSchemaGenerator; private readonly ResourceTypeSchemaGenerator _resourceTypeSchemaGenerator; private readonly SchemaRepository _resourceSchemaRepository = new(); - private readonly NullableReferenceSchemaGenerator _nullableReferenceSchemaGenerator; private readonly IDictionary _schemasForResourceFields; private readonly ResourceFieldValidationMetadataProvider _resourceFieldValidationMetadataProvider; private readonly RelationshipTypeFactory _relationshipTypeFactory; + private readonly NullabilityInfoContext _nullabilityInfoContext = new(); private readonly ResourceObjectDocumentationReader _resourceObjectDocumentationReader; public ResourceFieldObjectSchemaBuilder(ResourceTypeInfo resourceTypeInfo, ISchemaRepositoryAccessor schemaRepositoryAccessor, - SchemaGenerator defaultSchemaGenerator, ResourceTypeSchemaGenerator resourceTypeSchemaGenerator, JsonNamingPolicy? namingPolicy, + SchemaGenerator defaultSchemaGenerator, ResourceTypeSchemaGenerator resourceTypeSchemaGenerator, ResourceFieldValidationMetadataProvider resourceFieldValidationMetadataProvider) { ArgumentGuard.NotNull(resourceTypeInfo); @@ -57,7 +57,6 @@ public ResourceFieldObjectSchemaBuilder(ResourceTypeInfo resourceTypeInfo, ISche _resourceTypeSchemaGenerator = resourceTypeSchemaGenerator; _resourceFieldValidationMetadataProvider = resourceFieldValidationMetadataProvider; - _nullableReferenceSchemaGenerator = new NullableReferenceSchemaGenerator(schemaRepositoryAccessor, namingPolicy); _relationshipTypeFactory = new RelationshipTypeFactory(resourceFieldValidationMetadataProvider); _schemasForResourceFields = GetFieldSchemas(); _resourceObjectDocumentationReader = new ResourceObjectDocumentationReader(); @@ -86,7 +85,15 @@ public void SetMembersOfAttributesObject(OpenApiSchema fullSchemaForAttributesOb if (matchingAttribute != null && matchingAttribute.Capabilities.HasFlag(requiredCapability)) { - AddAttributeSchemaToResourceObject(matchingAttribute, fullSchemaForAttributesObject, resourceFieldSchema); + bool isPrimitiveOpenApiType = resourceFieldSchema.AllOf.IsNullOrEmpty(); + + // Types like enum and complex attributes are not primitive and handled as reference schemas. + if (!isPrimitiveOpenApiType) + { + EnsureAttributeSchemaIsExposed(resourceFieldSchema, matchingAttribute); + } + + fullSchemaForAttributesObject.Properties[matchingAttribute.PublicName] = resourceFieldSchema; resourceFieldSchema.Nullable = _resourceFieldValidationMetadataProvider.IsNullable(matchingAttribute); @@ -107,21 +114,33 @@ private static AttrCapabilities GetRequiredCapabilityForAttributes(Type resource resourceObjectOpenType == typeof(ResourceObjectInPatchRequest<>) ? AttrCapabilities.AllowChange : throw new UnreachableCodeException(); } - private void AddAttributeSchemaToResourceObject(AttrAttribute attribute, OpenApiSchema attributesObjectSchema, OpenApiSchema resourceAttributeSchema) + private void EnsureAttributeSchemaIsExposed(OpenApiSchema attributeReferenceSchema, AttrAttribute attribute) { - if (resourceAttributeSchema.Reference != null && !_schemaRepositoryAccessor.Current.TryLookupByType(attribute.Property.PropertyType, out _)) + Type nonNullableTypeInPropertyType = GetRepresentedTypeForAttributeSchema(attribute); + + if (_schemaRepositoryAccessor.Current.TryLookupByType(nonNullableTypeInPropertyType, out _)) { - ExposeSchema(resourceAttributeSchema.Reference, attribute.Property.PropertyType); + return; } - attributesObjectSchema.Properties.Add(attribute.PublicName, resourceAttributeSchema); + string schemaId = attributeReferenceSchema.UnwrapExtendedReferenceSchema().Reference.Id; + + OpenApiSchema fullSchema = _resourceSchemaRepository.Schemas[schemaId]; + _schemaRepositoryAccessor.Current.AddDefinition(schemaId, fullSchema); + _schemaRepositoryAccessor.Current.RegisterType(nonNullableTypeInPropertyType, schemaId); } - private void ExposeSchema(OpenApiReference openApiReference, Type typeRepresentedBySchema) + private Type GetRepresentedTypeForAttributeSchema(AttrAttribute attribute) { - OpenApiSchema fullSchema = _resourceSchemaRepository.Schemas[openApiReference.Id]; - _schemaRepositoryAccessor.Current.AddDefinition(openApiReference.Id, fullSchema); - _schemaRepositoryAccessor.Current.RegisterType(typeRepresentedBySchema, openApiReference.Id); + NullabilityInfo attributeNullabilityInfo = _nullabilityInfoContext.Create(attribute.Property); + + bool isNullable = attributeNullabilityInfo is { ReadState: NullabilityState.Nullable, WriteState: NullabilityState.Nullable }; + + Type nonNullableTypeInPropertyType = isNullable + ? Nullable.GetUnderlyingType(attribute.Property.PropertyType) ?? attribute.Property.PropertyType + : attribute.Property.PropertyType; + + return nonNullableTypeInPropertyType; } private bool IsFieldRequired(ResourceFieldAttribute field) @@ -182,9 +201,18 @@ private void AddRelationshipSchemaToResourceObject(RelationshipAttribute relatio { Type relationshipSchemaType = GetRelationshipSchemaType(relationship, _resourceTypeInfo.ResourceObjectOpenType); - OpenApiSchema relationshipSchema = GetReferenceSchemaForRelationship(relationshipSchemaType) ?? CreateRelationshipSchema(relationshipSchemaType); + OpenApiSchema referenceSchemaForRelationship = + GetReferenceSchemaForRelationship(relationshipSchemaType) ?? CreateRelationshipReferenceSchema(relationshipSchemaType); + + var extendedReferenceSchemaForRelationship = new OpenApiSchema + { + AllOf = new List + { + referenceSchemaForRelationship + } + }; - fullSchemaForRelationshipsObject.Properties.Add(relationship.PublicName, relationshipSchema); + fullSchemaForRelationshipsObject.Properties.Add(relationship.PublicName, extendedReferenceSchemaForRelationship); if (IsFieldRequired(relationship)) { @@ -205,7 +233,7 @@ private Type GetRelationshipSchemaType(RelationshipAttribute relationship, Type return referenceSchema; } - private OpenApiSchema CreateRelationshipSchema(Type relationshipSchemaType) + private OpenApiSchema CreateRelationshipReferenceSchema(Type relationshipSchemaType) { OpenApiSchema referenceSchema = _defaultSchemaGenerator.GenerateSchema(relationshipSchemaType, _schemaRepositoryAccessor.Current); @@ -213,7 +241,7 @@ private OpenApiSchema CreateRelationshipSchema(Type relationshipSchemaType) if (IsDataPropertyNullableInRelationshipSchemaType(relationshipSchemaType)) { - fullSchema.Properties[JsonApiPropertyName.Data] = _nullableReferenceSchemaGenerator.GenerateSchema(fullSchema.Properties[JsonApiPropertyName.Data]); + fullSchema.Properties[JsonApiPropertyName.Data].Nullable = true; } if (IsRelationshipInResponseType(relationshipSchemaType)) diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs index 4977b61025..98c35db59b 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs @@ -42,7 +42,7 @@ public ResourceObjectSchemaGenerator(SchemaGenerator defaultSchemaGenerator, IRe _resourceTypeSchemaGenerator = new ResourceTypeSchemaGenerator(schemaRepositoryAccessor, resourceGraph, options.SerializerOptions.PropertyNamingPolicy); _resourceFieldObjectSchemaBuilderFactory = resourceTypeInfo => new ResourceFieldObjectSchemaBuilder(resourceTypeInfo, schemaRepositoryAccessor, - defaultSchemaGenerator, _resourceTypeSchemaGenerator, options.SerializerOptions.PropertyNamingPolicy, resourceFieldValidationMetadataProvider); + defaultSchemaGenerator, _resourceTypeSchemaGenerator, resourceFieldValidationMetadataProvider); _resourceObjectDocumentationReader = new ResourceObjectDocumentationReader(); } @@ -108,7 +108,9 @@ private void SetResourceType(OpenApiSchema fullSchemaForResourceObject, Resource private void SetResourceAttributes(OpenApiSchema fullSchemaForResourceObject, ResourceFieldObjectSchemaBuilder builder) { - OpenApiSchema referenceSchemaForAttributesObject = fullSchemaForResourceObject.Properties[JsonApiPropertyName.Attributes]; + OpenApiSchema referenceSchemaForAttributesObject = + fullSchemaForResourceObject.Properties[JsonApiPropertyName.Attributes].UnwrapExtendedReferenceSchema(); + OpenApiSchema fullSchemaForAttributesObject = _schemaRepositoryAccessor.Current.Schemas[referenceSchemaForAttributesObject.Reference.Id]; builder.SetMembersOfAttributesObject(fullSchemaForAttributesObject); @@ -126,7 +128,9 @@ private void SetResourceAttributes(OpenApiSchema fullSchemaForResourceObject, Re private void SetResourceRelationships(OpenApiSchema fullSchemaForResourceObject, ResourceFieldObjectSchemaBuilder builder) { - OpenApiSchema referenceSchemaForRelationshipsObject = fullSchemaForResourceObject.Properties[JsonApiPropertyName.Relationships]; + OpenApiSchema referenceSchemaForRelationshipsObject = + fullSchemaForResourceObject.Properties[JsonApiPropertyName.Relationships].UnwrapExtendedReferenceSchema(); + OpenApiSchema fullSchemaForRelationshipsObject = _schemaRepositoryAccessor.Current.Schemas[referenceSchemaForRelationshipsObject.Reference.Id]; builder.SetMembersOfRelationshipsObject(fullSchemaForRelationshipsObject); diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeSchemaGenerator.cs index 592a8ed860..6db24901b2 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeSchemaGenerator.cs @@ -28,9 +28,9 @@ public OpenApiSchema Get(Type resourceClrType) { ArgumentGuard.NotNull(resourceClrType); - if (_resourceClrTypeSchemaCache.TryGetValue(resourceClrType, out OpenApiSchema? referenceSchema)) + if (_resourceClrTypeSchemaCache.TryGetValue(resourceClrType, out OpenApiSchema? extendedReferenceSchema)) { - return referenceSchema; + return extendedReferenceSchema; } ResourceType resourceType = _resourceGraph.GetResourceType(resourceClrType); @@ -46,7 +46,7 @@ public OpenApiSchema Get(Type resourceClrType) string schemaId = GetSchemaId(resourceType); - referenceSchema = new OpenApiSchema + var referenceSchema = new OpenApiSchema { Reference = new OpenApiReference { @@ -55,10 +55,18 @@ public OpenApiSchema Get(Type resourceClrType) } }; - _schemaRepositoryAccessor.Current.AddDefinition(referenceSchema.Reference.Id, fullSchema); - _resourceClrTypeSchemaCache.Add(resourceType.ClrType, referenceSchema); + extendedReferenceSchema = new OpenApiSchema + { + AllOf = new List + { + referenceSchema + } + }; + + _schemaRepositoryAccessor.Current.AddDefinition(schemaId, fullSchema); + _resourceClrTypeSchemaCache.Add(resourceType.ClrType, extendedReferenceSchema); - return referenceSchema; + return extendedReferenceSchema; } private string GetSchemaId(ResourceType resourceType) diff --git a/test/OpenApiClientTests/LegacyClient/swagger.g.json b/test/OpenApiClientTests/LegacyClient/swagger.g.json index 246cd45865..e95d8261b4 100644 --- a/test/OpenApiClientTests/LegacyClient/swagger.g.json +++ b/test/OpenApiClientTests/LegacyClient/swagger.g.json @@ -49,7 +49,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/airplane-post-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-post-request-document" + } + ] } } } @@ -166,7 +170,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/airplane-patch-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-patch-request-document" + } + ] } } } @@ -371,7 +379,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -413,7 +425,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -455,7 +471,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -520,7 +540,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/flight-attendant-post-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-post-request-document" + } + ] } } } @@ -637,7 +661,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/flight-attendant-patch-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-patch-request-document" + } + ] } } } @@ -842,7 +870,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -884,7 +916,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -926,7 +962,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -1092,7 +1132,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -1134,7 +1178,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -1176,7 +1224,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -1241,7 +1293,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/flight-post-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/flight-post-request-document" + } + ] } } } @@ -1358,7 +1414,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/flight-patch-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/flight-patch-request-document" + } + ] } } } @@ -1563,7 +1623,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" + } + ] } } } @@ -1729,7 +1793,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + } + ] } } } @@ -1771,7 +1839,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + } + ] } } } @@ -1813,7 +1885,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + } + ] } } } @@ -1979,7 +2055,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-passenger-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-passenger-in-request" + } + ] } } } @@ -2021,7 +2101,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-passenger-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-passenger-in-request" + } + ] } } } @@ -2063,7 +2147,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-passenger-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-passenger-in-request" + } + ] } } } @@ -2229,7 +2317,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-one-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-one-flight-attendant-in-request" + } + ] } } } @@ -2371,7 +2463,11 @@ "nullable": true }, "kind": { - "$ref": "#/components/schemas/aircraft-kind" + "allOf": [ + { + "$ref": "#/components/schemas/aircraft-kind" + } + ] } }, "additionalProperties": false @@ -2384,10 +2480,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-collection-document" + } + ] }, "data": { "type": "array", @@ -2410,17 +2514,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/airplane-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/airplane-attributes-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-attributes-in-patch-request" + } + ] }, "relationships": { - "$ref": "#/components/schemas/airplane-relationships-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-relationships-in-patch-request" + } + ] } }, "additionalProperties": false @@ -2432,13 +2548,25 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/airplane-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-resource-type" + } + ] }, "attributes": { - "$ref": "#/components/schemas/airplane-attributes-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-attributes-in-post-request" + } + ] }, "relationships": { - "$ref": "#/components/schemas/airplane-relationships-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-relationships-in-post-request" + } + ] } }, "additionalProperties": false @@ -2452,20 +2580,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/airplane-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/airplane-attributes-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-attributes-in-response" + } + ] }, "relationships": { - "$ref": "#/components/schemas/airplane-relationships-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-relationships-in-response" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-object" + } + ] }, "meta": { "type": "object", @@ -2481,7 +2625,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/airplane-data-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-data-in-patch-request" + } + ] } }, "additionalProperties": false @@ -2493,7 +2641,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/airplane-data-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-data-in-post-request" + } + ] } }, "additionalProperties": false @@ -2506,13 +2658,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "$ref": "#/components/schemas/airplane-data-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-data-in-response" + } + ] }, "meta": { "type": "object", @@ -2525,7 +2689,11 @@ "type": "object", "properties": { "flights": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } }, "additionalProperties": false @@ -2534,7 +2702,11 @@ "type": "object", "properties": { "flights": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } }, "additionalProperties": false @@ -2543,7 +2715,11 @@ "type": "object", "properties": { "flights": { - "$ref": "#/components/schemas/to-many-flight-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-response" + } + ] } }, "additionalProperties": false @@ -2641,10 +2817,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-collection-document" + } + ] }, "data": { "type": "array", @@ -2667,17 +2851,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-attendant-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/flight-attendant-attributes-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-attributes-in-patch-request" + } + ] }, "relationships": { - "$ref": "#/components/schemas/flight-attendant-relationships-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-relationships-in-patch-request" + } + ] } }, "additionalProperties": false @@ -2689,13 +2885,25 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-attendant-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-resource-type" + } + ] }, "attributes": { - "$ref": "#/components/schemas/flight-attendant-attributes-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-attributes-in-post-request" + } + ] }, "relationships": { - "$ref": "#/components/schemas/flight-attendant-relationships-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-relationships-in-post-request" + } + ] } }, "additionalProperties": false @@ -2709,20 +2917,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-attendant-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/flight-attendant-attributes-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-attributes-in-response" + } + ] }, "relationships": { - "$ref": "#/components/schemas/flight-attendant-relationships-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-relationships-in-response" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-object" + } + ] }, "meta": { "type": "object", @@ -2739,7 +2963,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-attendant-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-resource-type" + } + ] }, "id": { "minLength": 1, @@ -2756,10 +2984,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + } + ] }, "data": { "type": "array", @@ -2782,13 +3018,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-document" + } + ] }, "data": { - "$ref": "#/components/schemas/flight-attendant-identifier" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-identifier" + } + ] }, "meta": { "type": "object", @@ -2804,7 +3052,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/flight-attendant-data-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-data-in-patch-request" + } + ] } }, "additionalProperties": false @@ -2816,7 +3068,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/flight-attendant-data-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-data-in-post-request" + } + ] } }, "additionalProperties": false @@ -2829,13 +3085,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "$ref": "#/components/schemas/flight-attendant-data-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-data-in-response" + } + ] }, "meta": { "type": "object", @@ -2848,10 +3116,18 @@ "type": "object", "properties": { "scheduled-for-flights": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] }, "purser-on-flights": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } }, "additionalProperties": false @@ -2860,10 +3136,18 @@ "type": "object", "properties": { "scheduled-for-flights": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] }, "purser-on-flights": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } }, "additionalProperties": false @@ -2872,10 +3156,18 @@ "type": "object", "properties": { "scheduled-for-flights": { - "$ref": "#/components/schemas/to-many-flight-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-response" + } + ] }, "purser-on-flights": { - "$ref": "#/components/schemas/to-many-flight-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-response" + } + ] } }, "additionalProperties": false @@ -2894,13 +3186,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "$ref": "#/components/schemas/flight-attendant-data-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-data-in-response" + } + ] }, "meta": { "type": "object", @@ -2922,7 +3226,11 @@ "nullable": true }, "operated-by": { - "$ref": "#/components/schemas/airline" + "allOf": [ + { + "$ref": "#/components/schemas/airline" + } + ] } }, "additionalProperties": false @@ -2944,7 +3252,11 @@ "nullable": true }, "operated-by": { - "$ref": "#/components/schemas/airline" + "allOf": [ + { + "$ref": "#/components/schemas/airline" + } + ] }, "departs-at": { "type": "string", @@ -2973,10 +3285,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-collection-document" + } + ] }, "data": { "type": "array", @@ -2999,17 +3319,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/flight-attributes-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attributes-in-patch-request" + } + ] }, "relationships": { - "$ref": "#/components/schemas/flight-relationships-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-relationships-in-patch-request" + } + ] } }, "additionalProperties": false @@ -3021,10 +3353,18 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-resource-type" + } + ] }, "relationships": { - "$ref": "#/components/schemas/flight-relationships-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-relationships-in-post-request" + } + ] } }, "additionalProperties": false @@ -3038,20 +3378,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/flight-attributes-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attributes-in-response" + } + ] }, "relationships": { - "$ref": "#/components/schemas/flight-relationships-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-relationships-in-response" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-object" + } + ] }, "meta": { "type": "object", @@ -3068,7 +3424,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-resource-type" + } + ] }, "id": { "minLength": 1, @@ -3085,10 +3445,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + } + ] }, "data": { "type": "array", @@ -3110,7 +3478,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/flight-data-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-data-in-patch-request" + } + ] } }, "additionalProperties": false @@ -3122,7 +3494,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/flight-data-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-data-in-post-request" + } + ] } }, "additionalProperties": false @@ -3135,13 +3511,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "$ref": "#/components/schemas/flight-data-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-data-in-response" + } + ] }, "meta": { "type": "object", @@ -3154,16 +3542,32 @@ "type": "object", "properties": { "cabin-crew-members": { - "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + } + ] }, "purser": { - "$ref": "#/components/schemas/to-one-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-one-flight-attendant-in-request" + } + ] }, "backup-purser": { - "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" + } + ] }, "passengers": { - "$ref": "#/components/schemas/to-many-passenger-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-passenger-in-request" + } + ] } }, "additionalProperties": false @@ -3175,16 +3579,32 @@ "type": "object", "properties": { "cabin-crew-members": { - "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + } + ] }, "purser": { - "$ref": "#/components/schemas/to-one-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-one-flight-attendant-in-request" + } + ] }, "backup-purser": { - "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" + } + ] }, "passengers": { - "$ref": "#/components/schemas/to-many-passenger-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-passenger-in-request" + } + ] } }, "additionalProperties": false @@ -3196,16 +3616,32 @@ "type": "object", "properties": { "cabin-crew-members": { - "$ref": "#/components/schemas/to-many-flight-attendant-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-attendant-in-response" + } + ] }, "purser": { - "$ref": "#/components/schemas/to-one-flight-attendant-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-one-flight-attendant-in-response" + } + ] }, "backup-purser": { - "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-response" + } + ] }, "passengers": { - "$ref": "#/components/schemas/to-many-passenger-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-passenger-in-response" + } + ] } }, "additionalProperties": false @@ -3374,29 +3810,6 @@ }, "additionalProperties": false }, - "null-value": { - "not": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "boolean" - }, - { - "type": "object" - }, - { - "type": "array" - } - ], - "items": { } - }, - "nullable": true - }, "nullable-flight-attendant-identifier-response-document": { "required": [ "data", @@ -3405,20 +3818,26 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-document" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/flight-attendant-identifier" - }, - { - "$ref": "#/components/schemas/null-value" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -3435,20 +3854,26 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/flight-attendant-data-in-response" - }, - { - "$ref": "#/components/schemas/null-value" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -3464,14 +3889,12 @@ "type": "object", "properties": { "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/flight-attendant-identifier" - }, - { - "$ref": "#/components/schemas/null-value" } - ] + ], + "nullable": true } }, "additionalProperties": false @@ -3483,17 +3906,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/flight-attendant-identifier" - }, - { - "$ref": "#/components/schemas/null-value" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -3510,7 +3935,11 @@ "nullable": true }, "cabin-area": { - "$ref": "#/components/schemas/cabin-area" + "allOf": [ + { + "$ref": "#/components/schemas/cabin-area" + } + ] } }, "additionalProperties": false @@ -3523,10 +3952,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-collection-document" + } + ] }, "data": { "type": "array", @@ -3550,17 +3987,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/passenger-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/passenger-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/passenger-attributes-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/passenger-attributes-in-response" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-object" + } + ] }, "meta": { "type": "object", @@ -3577,7 +4026,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/passenger-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/passenger-resource-type" + } + ] }, "id": { "minLength": 1, @@ -3594,10 +4047,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + } + ] }, "data": { "type": "array", @@ -3640,7 +4101,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { "type": "array", @@ -3677,7 +4142,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { "type": "array", @@ -3714,7 +4183,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { "type": "array", @@ -3736,7 +4209,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/flight-attendant-identifier" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-identifier" + } + ] } }, "additionalProperties": false @@ -3748,10 +4225,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { - "$ref": "#/components/schemas/flight-attendant-identifier" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-identifier" + } + ] }, "meta": { "type": "object", diff --git a/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json b/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json index 36f4e576cb..148b2203bd 100644 --- a/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json +++ b/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json @@ -49,7 +49,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/supermarketPostRequestDocument" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketPostRequestDocument" + } + ] } } } @@ -169,7 +173,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/supermarketPatchRequestDocument" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketPatchRequestDocument" + } + ] } } } @@ -380,7 +388,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/nullableToOneStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneStaffMemberInRequest" + } + ] } } } @@ -551,7 +563,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyStaffMemberInRequest" + } + ] } } } @@ -594,7 +610,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyStaffMemberInRequest" + } + ] } } } @@ -637,7 +657,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyStaffMemberInRequest" + } + ] } } } @@ -808,7 +832,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toOneStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneStaffMemberInRequest" + } + ] } } } @@ -990,29 +1018,6 @@ }, "additionalProperties": false }, - "nullValue": { - "not": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "boolean" - }, - { - "type": "object" - }, - { - "type": "array" - } - ], - "items": { } - }, - "nullable": true - }, "nullableStaffMemberIdentifierResponseDocument": { "required": [ "data", @@ -1021,20 +1026,26 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/staffMemberIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1051,20 +1062,26 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/staffMemberDataInResponse" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1080,14 +1097,12 @@ "type": "object", "properties": { "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/staffMemberIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true } }, "additionalProperties": false @@ -1099,17 +1114,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/staffMemberIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1142,10 +1159,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1169,17 +1194,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/staffMemberResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/staffMemberResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/staffMemberAttributesInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/staffMemberAttributesInResponse" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceObject" + } + ] }, "meta": { "type": "object", @@ -1196,7 +1233,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/staffMemberResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/staffMemberResourceType" + } + ] }, "id": { "minLength": 1, @@ -1213,10 +1254,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1239,13 +1288,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/staffMemberIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/staffMemberIdentifier" + } + ] }, "meta": { "type": "object", @@ -1268,13 +1329,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/staffMemberDataInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/staffMemberDataInResponse" + } + ] }, "meta": { "type": "object", @@ -1290,7 +1363,11 @@ "type": "string" }, "kind": { - "$ref": "#/components/schemas/supermarketType" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketType" + } + ] } }, "additionalProperties": false @@ -1305,7 +1382,11 @@ "type": "string" }, "kind": { - "$ref": "#/components/schemas/supermarketType" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketType" + } + ] } }, "additionalProperties": false @@ -1320,7 +1401,11 @@ "type": "string" }, "kind": { - "$ref": "#/components/schemas/supermarketType" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketType" + } + ] } }, "additionalProperties": false @@ -1333,10 +1418,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1359,17 +1452,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/supermarketResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/supermarketAttributesInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketAttributesInPatchRequest" + } + ] }, "relationships": { - "$ref": "#/components/schemas/supermarketRelationshipsInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketRelationshipsInPatchRequest" + } + ] } }, "additionalProperties": false @@ -1381,13 +1486,25 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/supermarketResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketResourceType" + } + ] }, "attributes": { - "$ref": "#/components/schemas/supermarketAttributesInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketAttributesInPostRequest" + } + ] }, "relationships": { - "$ref": "#/components/schemas/supermarketRelationshipsInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketRelationshipsInPostRequest" + } + ] } }, "additionalProperties": false @@ -1401,20 +1518,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/supermarketResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/supermarketAttributesInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketAttributesInResponse" + } + ] }, "relationships": { - "$ref": "#/components/schemas/supermarketRelationshipsInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketRelationshipsInResponse" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceObject" + } + ] }, "meta": { "type": "object", @@ -1430,7 +1563,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/supermarketDataInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketDataInPatchRequest" + } + ] } }, "additionalProperties": false @@ -1442,7 +1579,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/supermarketDataInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketDataInPostRequest" + } + ] } }, "additionalProperties": false @@ -1455,13 +1596,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/supermarketDataInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/supermarketDataInResponse" + } + ] }, "meta": { "type": "object", @@ -1474,13 +1627,25 @@ "type": "object", "properties": { "storeManager": { - "$ref": "#/components/schemas/toOneStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneStaffMemberInRequest" + } + ] }, "backupStoreManager": { - "$ref": "#/components/schemas/nullableToOneStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneStaffMemberInRequest" + } + ] }, "cashiers": { - "$ref": "#/components/schemas/toManyStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyStaffMemberInRequest" + } + ] } }, "additionalProperties": false @@ -1492,13 +1657,25 @@ "type": "object", "properties": { "storeManager": { - "$ref": "#/components/schemas/toOneStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneStaffMemberInRequest" + } + ] }, "backupStoreManager": { - "$ref": "#/components/schemas/nullableToOneStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneStaffMemberInRequest" + } + ] }, "cashiers": { - "$ref": "#/components/schemas/toManyStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyStaffMemberInRequest" + } + ] } }, "additionalProperties": false @@ -1510,13 +1687,25 @@ "type": "object", "properties": { "storeManager": { - "$ref": "#/components/schemas/toOneStaffMemberInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toOneStaffMemberInResponse" + } + ] }, "backupStoreManager": { - "$ref": "#/components/schemas/nullableToOneStaffMemberInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneStaffMemberInResponse" + } + ] }, "cashiers": { - "$ref": "#/components/schemas/toManyStaffMemberInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toManyStaffMemberInResponse" + } + ] } }, "additionalProperties": false @@ -1557,7 +1746,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { "type": "array", @@ -1579,7 +1772,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/staffMemberIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/staffMemberIdentifier" + } + ] } }, "additionalProperties": false @@ -1591,10 +1788,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { - "$ref": "#/components/schemas/staffMemberIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/staffMemberIdentifier" + } + ] }, "meta": { "type": "object", diff --git a/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json b/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json index 5f849605f2..d439357cae 100644 --- a/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json +++ b/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json @@ -49,7 +49,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/supermarket-post-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-post-request-document" + } + ] } } } @@ -169,7 +173,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/supermarket-patch-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-patch-request-document" + } + ] } } } @@ -380,7 +388,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/nullable-to-one-staff-member-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/nullable-to-one-staff-member-in-request" + } + ] } } } @@ -551,7 +563,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-staff-member-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-staff-member-in-request" + } + ] } } } @@ -594,7 +610,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-staff-member-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-staff-member-in-request" + } + ] } } } @@ -637,7 +657,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-staff-member-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-staff-member-in-request" + } + ] } } } @@ -808,7 +832,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-one-staff-member-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-one-staff-member-in-request" + } + ] } } } @@ -990,29 +1018,6 @@ }, "additionalProperties": false }, - "null-value": { - "not": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "boolean" - }, - { - "type": "object" - }, - { - "type": "array" - } - ], - "items": { } - }, - "nullable": true - }, "nullable-staff-member-identifier-response-document": { "required": [ "data", @@ -1021,20 +1026,26 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-document" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/staff-member-identifier" - }, - { - "$ref": "#/components/schemas/null-value" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1051,20 +1062,26 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/staff-member-data-in-response" - }, - { - "$ref": "#/components/schemas/null-value" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1080,14 +1097,12 @@ "type": "object", "properties": { "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/staff-member-identifier" - }, - { - "$ref": "#/components/schemas/null-value" } - ] + ], + "nullable": true } }, "additionalProperties": false @@ -1099,17 +1114,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/staff-member-identifier" - }, - { - "$ref": "#/components/schemas/null-value" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1142,10 +1159,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-collection-document" + } + ] }, "data": { "type": "array", @@ -1169,17 +1194,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/staff-member-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/staff-member-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/staff-member-attributes-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/staff-member-attributes-in-response" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-object" + } + ] }, "meta": { "type": "object", @@ -1196,7 +1233,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/staff-member-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/staff-member-resource-type" + } + ] }, "id": { "minLength": 1, @@ -1213,10 +1254,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + } + ] }, "data": { "type": "array", @@ -1239,13 +1288,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-document" + } + ] }, "data": { - "$ref": "#/components/schemas/staff-member-identifier" + "allOf": [ + { + "$ref": "#/components/schemas/staff-member-identifier" + } + ] }, "meta": { "type": "object", @@ -1268,13 +1329,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "$ref": "#/components/schemas/staff-member-data-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/staff-member-data-in-response" + } + ] }, "meta": { "type": "object", @@ -1290,7 +1363,11 @@ "type": "string" }, "kind": { - "$ref": "#/components/schemas/supermarket-type" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-type" + } + ] } }, "additionalProperties": false @@ -1305,7 +1382,11 @@ "type": "string" }, "kind": { - "$ref": "#/components/schemas/supermarket-type" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-type" + } + ] } }, "additionalProperties": false @@ -1320,7 +1401,11 @@ "type": "string" }, "kind": { - "$ref": "#/components/schemas/supermarket-type" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-type" + } + ] } }, "additionalProperties": false @@ -1333,10 +1418,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-collection-document" + } + ] }, "data": { "type": "array", @@ -1359,17 +1452,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/supermarket-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/supermarket-attributes-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-attributes-in-patch-request" + } + ] }, "relationships": { - "$ref": "#/components/schemas/supermarket-relationships-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-relationships-in-patch-request" + } + ] } }, "additionalProperties": false @@ -1381,13 +1486,25 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/supermarket-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-resource-type" + } + ] }, "attributes": { - "$ref": "#/components/schemas/supermarket-attributes-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-attributes-in-post-request" + } + ] }, "relationships": { - "$ref": "#/components/schemas/supermarket-relationships-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-relationships-in-post-request" + } + ] } }, "additionalProperties": false @@ -1401,20 +1518,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/supermarket-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/supermarket-attributes-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-attributes-in-response" + } + ] }, "relationships": { - "$ref": "#/components/schemas/supermarket-relationships-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-relationships-in-response" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-object" + } + ] }, "meta": { "type": "object", @@ -1430,7 +1563,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/supermarket-data-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-data-in-patch-request" + } + ] } }, "additionalProperties": false @@ -1442,7 +1579,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/supermarket-data-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-data-in-post-request" + } + ] } }, "additionalProperties": false @@ -1455,13 +1596,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "$ref": "#/components/schemas/supermarket-data-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/supermarket-data-in-response" + } + ] }, "meta": { "type": "object", @@ -1474,13 +1627,25 @@ "type": "object", "properties": { "store-manager": { - "$ref": "#/components/schemas/to-one-staff-member-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-one-staff-member-in-request" + } + ] }, "backup-store-manager": { - "$ref": "#/components/schemas/nullable-to-one-staff-member-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/nullable-to-one-staff-member-in-request" + } + ] }, "cashiers": { - "$ref": "#/components/schemas/to-many-staff-member-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-staff-member-in-request" + } + ] } }, "additionalProperties": false @@ -1492,13 +1657,25 @@ "type": "object", "properties": { "store-manager": { - "$ref": "#/components/schemas/to-one-staff-member-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-one-staff-member-in-request" + } + ] }, "backup-store-manager": { - "$ref": "#/components/schemas/nullable-to-one-staff-member-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/nullable-to-one-staff-member-in-request" + } + ] }, "cashiers": { - "$ref": "#/components/schemas/to-many-staff-member-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-staff-member-in-request" + } + ] } }, "additionalProperties": false @@ -1510,13 +1687,25 @@ "type": "object", "properties": { "store-manager": { - "$ref": "#/components/schemas/to-one-staff-member-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-one-staff-member-in-response" + } + ] }, "backup-store-manager": { - "$ref": "#/components/schemas/nullable-to-one-staff-member-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/nullable-to-one-staff-member-in-response" + } + ] }, "cashiers": { - "$ref": "#/components/schemas/to-many-staff-member-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-staff-member-in-response" + } + ] } }, "additionalProperties": false @@ -1557,7 +1746,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { "type": "array", @@ -1579,7 +1772,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/staff-member-identifier" + "allOf": [ + { + "$ref": "#/components/schemas/staff-member-identifier" + } + ] } }, "additionalProperties": false @@ -1591,10 +1788,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { - "$ref": "#/components/schemas/staff-member-identifier" + "allOf": [ + { + "$ref": "#/components/schemas/staff-member-identifier" + } + ] }, "meta": { "type": "object", diff --git a/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json b/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json index 20ecb900cd..ed70846149 100644 --- a/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json +++ b/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json @@ -49,7 +49,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/SupermarketPostRequestDocument" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketPostRequestDocument" + } + ] } } } @@ -169,7 +173,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/SupermarketPatchRequestDocument" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketPatchRequestDocument" + } + ] } } } @@ -380,7 +388,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/NullableToOneStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/NullableToOneStaffMemberInRequest" + } + ] } } } @@ -551,7 +563,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/ToManyStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/ToManyStaffMemberInRequest" + } + ] } } } @@ -594,7 +610,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/ToManyStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/ToManyStaffMemberInRequest" + } + ] } } } @@ -637,7 +657,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/ToManyStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/ToManyStaffMemberInRequest" + } + ] } } } @@ -808,7 +832,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/ToOneStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/ToOneStaffMemberInRequest" + } + ] } } } @@ -990,29 +1018,6 @@ }, "additionalProperties": false }, - "NullValue": { - "not": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "boolean" - }, - { - "type": "object" - }, - { - "type": "array" - } - ], - "items": { } - }, - "nullable": true - }, "NullableStaffMemberIdentifierResponseDocument": { "required": [ "data", @@ -1021,20 +1026,26 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/JsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/LinksInResourceIdentifierDocument" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInResourceIdentifierDocument" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/StaffMemberIdentifier" - }, - { - "$ref": "#/components/schemas/NullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1051,20 +1062,26 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/JsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/LinksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInResourceDocument" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/StaffMemberDataInResponse" - }, - { - "$ref": "#/components/schemas/NullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1080,14 +1097,12 @@ "type": "object", "properties": { "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/StaffMemberIdentifier" - }, - { - "$ref": "#/components/schemas/NullValue" } - ] + ], + "nullable": true } }, "additionalProperties": false @@ -1099,17 +1114,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/LinksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInRelationshipObject" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/StaffMemberIdentifier" - }, - { - "$ref": "#/components/schemas/NullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1142,10 +1159,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/JsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/LinksInResourceCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInResourceCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1169,17 +1194,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/StaffMemberResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/StaffMemberResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/StaffMemberAttributesInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/StaffMemberAttributesInResponse" + } + ] }, "links": { - "$ref": "#/components/schemas/LinksInResourceObject" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInResourceObject" + } + ] }, "meta": { "type": "object", @@ -1196,7 +1233,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/StaffMemberResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/StaffMemberResourceType" + } + ] }, "id": { "minLength": 1, @@ -1213,10 +1254,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/JsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/LinksInResourceIdentifierCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInResourceIdentifierCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1239,13 +1288,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/JsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/LinksInResourceIdentifierDocument" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInResourceIdentifierDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/StaffMemberIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/StaffMemberIdentifier" + } + ] }, "meta": { "type": "object", @@ -1268,13 +1329,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/JsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/LinksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInResourceDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/StaffMemberDataInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/StaffMemberDataInResponse" + } + ] }, "meta": { "type": "object", @@ -1290,7 +1363,11 @@ "type": "string" }, "Kind": { - "$ref": "#/components/schemas/SupermarketType" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketType" + } + ] } }, "additionalProperties": false @@ -1305,7 +1382,11 @@ "type": "string" }, "Kind": { - "$ref": "#/components/schemas/SupermarketType" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketType" + } + ] } }, "additionalProperties": false @@ -1320,7 +1401,11 @@ "type": "string" }, "Kind": { - "$ref": "#/components/schemas/SupermarketType" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketType" + } + ] } }, "additionalProperties": false @@ -1333,10 +1418,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/JsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/LinksInResourceCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInResourceCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1359,17 +1452,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/SupermarketResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/SupermarketAttributesInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketAttributesInPatchRequest" + } + ] }, "relationships": { - "$ref": "#/components/schemas/SupermarketRelationshipsInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketRelationshipsInPatchRequest" + } + ] } }, "additionalProperties": false @@ -1381,13 +1486,25 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/SupermarketResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketResourceType" + } + ] }, "attributes": { - "$ref": "#/components/schemas/SupermarketAttributesInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketAttributesInPostRequest" + } + ] }, "relationships": { - "$ref": "#/components/schemas/SupermarketRelationshipsInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketRelationshipsInPostRequest" + } + ] } }, "additionalProperties": false @@ -1401,20 +1518,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/SupermarketResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/SupermarketAttributesInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketAttributesInResponse" + } + ] }, "relationships": { - "$ref": "#/components/schemas/SupermarketRelationshipsInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketRelationshipsInResponse" + } + ] }, "links": { - "$ref": "#/components/schemas/LinksInResourceObject" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInResourceObject" + } + ] }, "meta": { "type": "object", @@ -1430,7 +1563,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/SupermarketDataInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketDataInPatchRequest" + } + ] } }, "additionalProperties": false @@ -1442,7 +1579,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/SupermarketDataInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketDataInPostRequest" + } + ] } }, "additionalProperties": false @@ -1455,13 +1596,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" + "allOf": [ + { + "$ref": "#/components/schemas/JsonapiObject" + } + ] }, "links": { - "$ref": "#/components/schemas/LinksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInResourceDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/SupermarketDataInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/SupermarketDataInResponse" + } + ] }, "meta": { "type": "object", @@ -1474,13 +1627,25 @@ "type": "object", "properties": { "StoreManager": { - "$ref": "#/components/schemas/ToOneStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/ToOneStaffMemberInRequest" + } + ] }, "BackupStoreManager": { - "$ref": "#/components/schemas/NullableToOneStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/NullableToOneStaffMemberInRequest" + } + ] }, "Cashiers": { - "$ref": "#/components/schemas/ToManyStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/ToManyStaffMemberInRequest" + } + ] } }, "additionalProperties": false @@ -1492,13 +1657,25 @@ "type": "object", "properties": { "StoreManager": { - "$ref": "#/components/schemas/ToOneStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/ToOneStaffMemberInRequest" + } + ] }, "BackupStoreManager": { - "$ref": "#/components/schemas/NullableToOneStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/NullableToOneStaffMemberInRequest" + } + ] }, "Cashiers": { - "$ref": "#/components/schemas/ToManyStaffMemberInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/ToManyStaffMemberInRequest" + } + ] } }, "additionalProperties": false @@ -1510,13 +1687,25 @@ "type": "object", "properties": { "StoreManager": { - "$ref": "#/components/schemas/ToOneStaffMemberInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/ToOneStaffMemberInResponse" + } + ] }, "BackupStoreManager": { - "$ref": "#/components/schemas/NullableToOneStaffMemberInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/NullableToOneStaffMemberInResponse" + } + ] }, "Cashiers": { - "$ref": "#/components/schemas/ToManyStaffMemberInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/ToManyStaffMemberInResponse" + } + ] } }, "additionalProperties": false @@ -1557,7 +1746,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/LinksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInRelationshipObject" + } + ] }, "data": { "type": "array", @@ -1579,7 +1772,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/StaffMemberIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/StaffMemberIdentifier" + } + ] } }, "additionalProperties": false @@ -1591,10 +1788,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/LinksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/LinksInRelationshipObject" + } + ] }, "data": { - "$ref": "#/components/schemas/StaffMemberIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/StaffMemberIdentifier" + } + ] }, "meta": { "type": "object", diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json index 6a62f505a2..993604786b 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json @@ -49,7 +49,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/resourcePostRequestDocument" + "allOf": [ + { + "$ref": "#/components/schemas/resourcePostRequestDocument" + } + ] } } } @@ -169,7 +173,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/resourcePatchRequestDocument" + "allOf": [ + { + "$ref": "#/components/schemas/resourcePatchRequestDocument" + } + ] } } } @@ -380,7 +388,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -423,7 +435,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -466,7 +482,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -637,7 +657,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] } } } @@ -808,7 +832,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -851,7 +879,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -894,7 +926,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1065,7 +1101,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] } } } @@ -1097,7 +1137,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1121,14 +1165,22 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/emptyResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/emptyResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "links": { - "$ref": "#/components/schemas/linksInResourceObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceObject" + } + ] }, "meta": { "type": "object", @@ -1145,7 +1197,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/emptyResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/emptyResourceType" + } + ] }, "id": { "minLength": 1, @@ -1162,7 +1218,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1341,29 +1401,6 @@ }, "additionalProperties": false }, - "nullValue": { - "not": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "boolean" - }, - { - "type": "object" - }, - { - "type": "array" - } - ], - "items": { } - }, - "nullable": true - }, "nullableEmptyIdentifierResponseDocument": { "required": [ "data", @@ -1372,17 +1409,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1399,17 +1438,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyDataInResponse" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1425,14 +1466,12 @@ "type": "object", "properties": { "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true } }, "additionalProperties": false @@ -1444,17 +1483,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1580,7 +1621,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1603,17 +1648,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/resourceResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/resourceResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/resourceAttributesInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceAttributesInPatchRequest" + } + ] }, "relationships": { - "$ref": "#/components/schemas/resourceRelationshipsInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceRelationshipsInPatchRequest" + } + ] } }, "additionalProperties": false @@ -1625,13 +1682,25 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/resourceResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/resourceResourceType" + } + ] }, "attributes": { - "$ref": "#/components/schemas/resourceAttributesInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceAttributesInPostRequest" + } + ] }, "relationships": { - "$ref": "#/components/schemas/resourceRelationshipsInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceRelationshipsInPostRequest" + } + ] } }, "additionalProperties": false @@ -1645,20 +1714,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/resourceResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/resourceResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/resourceAttributesInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/resourceAttributesInResponse" + } + ] }, "relationships": { - "$ref": "#/components/schemas/resourceRelationshipsInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/resourceRelationshipsInResponse" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceObject" + } + ] }, "meta": { "type": "object", @@ -1674,7 +1759,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/resourceDataInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceDataInPatchRequest" + } + ] } }, "additionalProperties": false @@ -1686,7 +1775,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/resourceDataInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceDataInPostRequest" + } + ] } }, "additionalProperties": false @@ -1699,10 +1792,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/resourceDataInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/resourceDataInResponse" + } + ] }, "meta": { "type": "object", @@ -1715,16 +1816,32 @@ "type": "object", "properties": { "toOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] }, "requiredToOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] }, "toMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] }, "requiredToMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } }, "additionalProperties": false @@ -1737,16 +1854,32 @@ "type": "object", "properties": { "toOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] }, "requiredToOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] }, "toMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] }, "requiredToMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } }, "additionalProperties": false @@ -1759,16 +1892,32 @@ "type": "object", "properties": { "toOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInResponse" + } + ] }, "requiredToOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInResponse" + } + ] }, "toMany": { - "$ref": "#/components/schemas/toManyEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInResponse" + } + ] }, "requiredToMany": { - "$ref": "#/components/schemas/toManyEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInResponse" + } + ] } }, "additionalProperties": false @@ -1801,7 +1950,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { "type": "array", diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json index 8dd6c83f5c..3cd727b975 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json @@ -49,7 +49,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/resourcePostRequestDocument" + "allOf": [ + { + "$ref": "#/components/schemas/resourcePostRequestDocument" + } + ] } } } @@ -169,7 +173,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/resourcePatchRequestDocument" + "allOf": [ + { + "$ref": "#/components/schemas/resourcePatchRequestDocument" + } + ] } } } @@ -380,7 +388,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -423,7 +435,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -466,7 +482,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -637,7 +657,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] } } } @@ -808,7 +832,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -851,7 +879,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -894,7 +926,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1065,7 +1101,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] } } } @@ -1097,7 +1137,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1121,14 +1165,22 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/emptyResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/emptyResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "links": { - "$ref": "#/components/schemas/linksInResourceObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceObject" + } + ] }, "meta": { "type": "object", @@ -1145,7 +1197,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/emptyResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/emptyResourceType" + } + ] }, "id": { "minLength": 1, @@ -1162,7 +1218,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1185,10 +1245,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/emptyIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/emptyIdentifier" + } + ] }, "meta": { "type": "object", @@ -1211,10 +1279,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/emptyDataInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/emptyDataInResponse" + } + ] }, "meta": { "type": "object", @@ -1381,29 +1457,6 @@ }, "additionalProperties": false }, - "nullValue": { - "not": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "boolean" - }, - { - "type": "object" - }, - { - "type": "array" - } - ], - "items": { } - }, - "nullable": true - }, "nullableEmptyIdentifierResponseDocument": { "required": [ "data", @@ -1412,17 +1465,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1439,17 +1494,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyDataInResponse" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1465,14 +1522,12 @@ "type": "object", "properties": { "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true } }, "additionalProperties": false @@ -1484,17 +1539,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1612,7 +1669,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1635,17 +1696,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/resourceResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/resourceResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/resourceAttributesInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceAttributesInPatchRequest" + } + ] }, "relationships": { - "$ref": "#/components/schemas/resourceRelationshipsInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceRelationshipsInPatchRequest" + } + ] } }, "additionalProperties": false @@ -1657,13 +1730,25 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/resourceResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/resourceResourceType" + } + ] }, "attributes": { - "$ref": "#/components/schemas/resourceAttributesInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceAttributesInPostRequest" + } + ] }, "relationships": { - "$ref": "#/components/schemas/resourceRelationshipsInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceRelationshipsInPostRequest" + } + ] } }, "additionalProperties": false @@ -1677,20 +1762,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/resourceResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/resourceResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/resourceAttributesInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/resourceAttributesInResponse" + } + ] }, "relationships": { - "$ref": "#/components/schemas/resourceRelationshipsInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/resourceRelationshipsInResponse" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceObject" + } + ] }, "meta": { "type": "object", @@ -1706,7 +1807,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/resourceDataInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceDataInPatchRequest" + } + ] } }, "additionalProperties": false @@ -1718,7 +1823,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/resourceDataInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceDataInPostRequest" + } + ] } }, "additionalProperties": false @@ -1731,10 +1840,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/resourceDataInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/resourceDataInResponse" + } + ] }, "meta": { "type": "object", @@ -1747,16 +1864,32 @@ "type": "object", "properties": { "toOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] }, "requiredToOne": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] }, "toMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] }, "requiredToMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } }, "additionalProperties": false @@ -1768,16 +1901,32 @@ "type": "object", "properties": { "toOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] }, "requiredToOne": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] }, "toMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] }, "requiredToMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } }, "additionalProperties": false @@ -1789,16 +1938,32 @@ "type": "object", "properties": { "toOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInResponse" + } + ] }, "requiredToOne": { - "$ref": "#/components/schemas/toOneEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInResponse" + } + ] }, "toMany": { - "$ref": "#/components/schemas/toManyEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInResponse" + } + ] }, "requiredToMany": { - "$ref": "#/components/schemas/toManyEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInResponse" + } + ] } }, "additionalProperties": false @@ -1831,7 +1996,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { "type": "array", @@ -1853,7 +2022,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/emptyIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/emptyIdentifier" + } + ] } }, "additionalProperties": false @@ -1865,10 +2038,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { - "$ref": "#/components/schemas/emptyIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/emptyIdentifier" + } + ] }, "meta": { "type": "object", diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json index ecd6333fbd..8f117b6f84 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json @@ -49,7 +49,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/resourcePostRequestDocument" + "allOf": [ + { + "$ref": "#/components/schemas/resourcePostRequestDocument" + } + ] } } } @@ -169,7 +173,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/resourcePatchRequestDocument" + "allOf": [ + { + "$ref": "#/components/schemas/resourcePatchRequestDocument" + } + ] } } } @@ -380,7 +388,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] } } } @@ -551,7 +563,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] } } } @@ -722,7 +738,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] } } } @@ -893,7 +913,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] } } } @@ -1064,7 +1088,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1107,7 +1135,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1150,7 +1182,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1321,7 +1357,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1364,7 +1404,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1407,7 +1451,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1439,7 +1487,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1463,14 +1515,22 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/emptyResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/emptyResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "links": { - "$ref": "#/components/schemas/linksInResourceObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceObject" + } + ] }, "meta": { "type": "object", @@ -1487,7 +1547,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/emptyResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/emptyResourceType" + } + ] }, "id": { "minLength": 1, @@ -1504,7 +1568,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1527,10 +1595,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/emptyIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/emptyIdentifier" + } + ] }, "meta": { "type": "object", @@ -1553,10 +1629,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/emptyDataInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/emptyDataInResponse" + } + ] }, "meta": { "type": "object", @@ -1723,29 +1807,6 @@ }, "additionalProperties": false }, - "nullValue": { - "not": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "boolean" - }, - { - "type": "object" - }, - { - "type": "array" - } - ], - "items": { } - }, - "nullable": true - }, "nullableEmptyIdentifierResponseDocument": { "required": [ "data", @@ -1754,17 +1815,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1781,17 +1844,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyDataInResponse" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1807,14 +1872,12 @@ "type": "object", "properties": { "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true } }, "additionalProperties": false @@ -1826,17 +1889,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1985,7 +2050,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] }, "data": { "type": "array", @@ -2008,17 +2077,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/resourceResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/resourceResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/resourceAttributesInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceAttributesInPatchRequest" + } + ] }, "relationships": { - "$ref": "#/components/schemas/resourceRelationshipsInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceRelationshipsInPatchRequest" + } + ] } }, "additionalProperties": false @@ -2030,13 +2111,25 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/resourceResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/resourceResourceType" + } + ] }, "attributes": { - "$ref": "#/components/schemas/resourceAttributesInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceAttributesInPostRequest" + } + ] }, "relationships": { - "$ref": "#/components/schemas/resourceRelationshipsInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceRelationshipsInPostRequest" + } + ] } }, "additionalProperties": false @@ -2050,20 +2143,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/resourceResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/resourceResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/resourceAttributesInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/resourceAttributesInResponse" + } + ] }, "relationships": { - "$ref": "#/components/schemas/resourceRelationshipsInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/resourceRelationshipsInResponse" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceObject" + } + ] }, "meta": { "type": "object", @@ -2079,7 +2188,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/resourceDataInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceDataInPatchRequest" + } + ] } }, "additionalProperties": false @@ -2091,7 +2204,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/resourceDataInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceDataInPostRequest" + } + ] } }, "additionalProperties": false @@ -2104,10 +2221,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/resourceDataInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/resourceDataInResponse" + } + ] }, "meta": { "type": "object", @@ -2120,22 +2245,46 @@ "type": "object", "properties": { "nonNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] }, "requiredNonNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] }, "nullableToOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] }, "requiredNullableToOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] }, "toMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] }, "requiredToMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } }, "additionalProperties": false @@ -2149,22 +2298,46 @@ "type": "object", "properties": { "nonNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] }, "requiredNonNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] }, "nullableToOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] }, "requiredNullableToOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] }, "toMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] }, "requiredToMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } }, "additionalProperties": false @@ -2178,22 +2351,46 @@ "type": "object", "properties": { "nonNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInResponse" + } + ] }, "requiredNonNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInResponse" + } + ] }, "nullableToOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInResponse" + } + ] }, "requiredNullableToOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInResponse" + } + ] }, "toMany": { - "$ref": "#/components/schemas/toManyEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInResponse" + } + ] }, "requiredToMany": { - "$ref": "#/components/schemas/toManyEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInResponse" + } + ] } }, "additionalProperties": false @@ -2226,7 +2423,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { "type": "array", @@ -2248,7 +2449,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/emptyIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/emptyIdentifier" + } + ] } }, "additionalProperties": false @@ -2260,10 +2465,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { - "$ref": "#/components/schemas/emptyIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/emptyIdentifier" + } + ] }, "meta": { "type": "object", diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json index f751eac3b2..7df69520b9 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json @@ -49,7 +49,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/resourcePostRequestDocument" + "allOf": [ + { + "$ref": "#/components/schemas/resourcePostRequestDocument" + } + ] } } } @@ -169,7 +173,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/resourcePatchRequestDocument" + "allOf": [ + { + "$ref": "#/components/schemas/resourcePatchRequestDocument" + } + ] } } } @@ -380,7 +388,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] } } } @@ -551,7 +563,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] } } } @@ -722,7 +738,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] } } } @@ -893,7 +913,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] } } } @@ -1064,7 +1088,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1107,7 +1135,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1150,7 +1182,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1321,7 +1357,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1364,7 +1404,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1407,7 +1451,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } } } @@ -1439,7 +1487,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1463,14 +1515,22 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/emptyResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/emptyResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "links": { - "$ref": "#/components/schemas/linksInResourceObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceObject" + } + ] }, "meta": { "type": "object", @@ -1487,7 +1547,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/emptyResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/emptyResourceType" + } + ] }, "id": { "minLength": 1, @@ -1504,7 +1568,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + } + ] }, "data": { "type": "array", @@ -1527,10 +1595,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/emptyIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/emptyIdentifier" + } + ] }, "meta": { "type": "object", @@ -1553,10 +1629,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/emptyDataInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/emptyDataInResponse" + } + ] }, "meta": { "type": "object", @@ -1723,29 +1807,6 @@ }, "additionalProperties": false }, - "nullValue": { - "not": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "boolean" - }, - { - "type": "object" - }, - { - "type": "array" - } - ], - "items": { } - }, - "nullable": true - }, "nullableEmptyIdentifierResponseDocument": { "required": [ "data", @@ -1754,17 +1815,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1781,17 +1844,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyDataInResponse" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1807,14 +1872,12 @@ "type": "object", "properties": { "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true } }, "additionalProperties": false @@ -1826,17 +1889,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/emptyIdentifier" - }, - { - "$ref": "#/components/schemas/nullValue" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -1979,7 +2044,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] }, "data": { "type": "array", @@ -2002,17 +2071,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/resourceResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/resourceResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/resourceAttributesInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceAttributesInPatchRequest" + } + ] }, "relationships": { - "$ref": "#/components/schemas/resourceRelationshipsInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceRelationshipsInPatchRequest" + } + ] } }, "additionalProperties": false @@ -2024,13 +2105,25 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/resourceResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/resourceResourceType" + } + ] }, "attributes": { - "$ref": "#/components/schemas/resourceAttributesInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceAttributesInPostRequest" + } + ] }, "relationships": { - "$ref": "#/components/schemas/resourceRelationshipsInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceRelationshipsInPostRequest" + } + ] } }, "additionalProperties": false @@ -2044,20 +2137,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/resourceResourceType" + "allOf": [ + { + "$ref": "#/components/schemas/resourceResourceType" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/resourceAttributesInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/resourceAttributesInResponse" + } + ] }, "relationships": { - "$ref": "#/components/schemas/resourceRelationshipsInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/resourceRelationshipsInResponse" + } + ] }, "links": { - "$ref": "#/components/schemas/linksInResourceObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceObject" + } + ] }, "meta": { "type": "object", @@ -2073,7 +2182,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/resourceDataInPatchRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceDataInPatchRequest" + } + ] } }, "additionalProperties": false @@ -2085,7 +2198,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/resourceDataInPostRequest" + "allOf": [ + { + "$ref": "#/components/schemas/resourceDataInPostRequest" + } + ] } }, "additionalProperties": false @@ -2098,10 +2215,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInResourceDocument" + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] }, "data": { - "$ref": "#/components/schemas/resourceDataInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/resourceDataInResponse" + } + ] }, "meta": { "type": "object", @@ -2114,22 +2239,46 @@ "type": "object", "properties": { "nonNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] }, "requiredNonNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] }, "nullableToOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] }, "requiredNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] }, "toMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] }, "requiredToMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } }, "additionalProperties": false @@ -2143,22 +2292,46 @@ "type": "object", "properties": { "nonNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] }, "requiredNonNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] }, "nullableToOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInRequest" + } + ] }, "requiredNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInRequest" + } + ] }, "toMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] }, "requiredToMany": { - "$ref": "#/components/schemas/toManyEmptyInRequest" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInRequest" + } + ] } }, "additionalProperties": false @@ -2172,22 +2345,46 @@ "type": "object", "properties": { "nonNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInResponse" + } + ] }, "requiredNonNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInResponse" + } + ] }, "nullableToOne": { - "$ref": "#/components/schemas/nullableToOneEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneEmptyInResponse" + } + ] }, "requiredNullableToOne": { - "$ref": "#/components/schemas/toOneEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toOneEmptyInResponse" + } + ] }, "toMany": { - "$ref": "#/components/schemas/toManyEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInResponse" + } + ] }, "requiredToMany": { - "$ref": "#/components/schemas/toManyEmptyInResponse" + "allOf": [ + { + "$ref": "#/components/schemas/toManyEmptyInResponse" + } + ] } }, "additionalProperties": false @@ -2220,7 +2417,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { "type": "array", @@ -2242,7 +2443,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/emptyIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/emptyIdentifier" + } + ] } }, "additionalProperties": false @@ -2254,10 +2459,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationshipObject" + } + ] }, "data": { - "$ref": "#/components/schemas/emptyIdentifier" + "allOf": [ + { + "$ref": "#/components/schemas/emptyIdentifier" + } + ] }, "meta": { "type": "object", diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json b/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json index 246cd45865..e95d8261b4 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json +++ b/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json @@ -49,7 +49,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/airplane-post-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-post-request-document" + } + ] } } } @@ -166,7 +170,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/airplane-patch-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-patch-request-document" + } + ] } } } @@ -371,7 +379,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -413,7 +425,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -455,7 +471,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -520,7 +540,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/flight-attendant-post-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-post-request-document" + } + ] } } } @@ -637,7 +661,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/flight-attendant-patch-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-patch-request-document" + } + ] } } } @@ -842,7 +870,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -884,7 +916,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -926,7 +962,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -1092,7 +1132,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -1134,7 +1178,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -1176,7 +1224,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } } } @@ -1241,7 +1293,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/flight-post-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/flight-post-request-document" + } + ] } } } @@ -1358,7 +1414,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/flight-patch-request-document" + "allOf": [ + { + "$ref": "#/components/schemas/flight-patch-request-document" + } + ] } } } @@ -1563,7 +1623,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" + } + ] } } } @@ -1729,7 +1793,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + } + ] } } } @@ -1771,7 +1839,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + } + ] } } } @@ -1813,7 +1885,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + } + ] } } } @@ -1979,7 +2055,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-passenger-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-passenger-in-request" + } + ] } } } @@ -2021,7 +2101,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-passenger-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-passenger-in-request" + } + ] } } } @@ -2063,7 +2147,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-many-passenger-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-passenger-in-request" + } + ] } } } @@ -2229,7 +2317,11 @@ "content": { "application/vnd.api+json": { "schema": { - "$ref": "#/components/schemas/to-one-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-one-flight-attendant-in-request" + } + ] } } } @@ -2371,7 +2463,11 @@ "nullable": true }, "kind": { - "$ref": "#/components/schemas/aircraft-kind" + "allOf": [ + { + "$ref": "#/components/schemas/aircraft-kind" + } + ] } }, "additionalProperties": false @@ -2384,10 +2480,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-collection-document" + } + ] }, "data": { "type": "array", @@ -2410,17 +2514,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/airplane-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/airplane-attributes-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-attributes-in-patch-request" + } + ] }, "relationships": { - "$ref": "#/components/schemas/airplane-relationships-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-relationships-in-patch-request" + } + ] } }, "additionalProperties": false @@ -2432,13 +2548,25 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/airplane-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-resource-type" + } + ] }, "attributes": { - "$ref": "#/components/schemas/airplane-attributes-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-attributes-in-post-request" + } + ] }, "relationships": { - "$ref": "#/components/schemas/airplane-relationships-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-relationships-in-post-request" + } + ] } }, "additionalProperties": false @@ -2452,20 +2580,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/airplane-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/airplane-attributes-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-attributes-in-response" + } + ] }, "relationships": { - "$ref": "#/components/schemas/airplane-relationships-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-relationships-in-response" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-object" + } + ] }, "meta": { "type": "object", @@ -2481,7 +2625,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/airplane-data-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-data-in-patch-request" + } + ] } }, "additionalProperties": false @@ -2493,7 +2641,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/airplane-data-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-data-in-post-request" + } + ] } }, "additionalProperties": false @@ -2506,13 +2658,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "$ref": "#/components/schemas/airplane-data-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/airplane-data-in-response" + } + ] }, "meta": { "type": "object", @@ -2525,7 +2689,11 @@ "type": "object", "properties": { "flights": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } }, "additionalProperties": false @@ -2534,7 +2702,11 @@ "type": "object", "properties": { "flights": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } }, "additionalProperties": false @@ -2543,7 +2715,11 @@ "type": "object", "properties": { "flights": { - "$ref": "#/components/schemas/to-many-flight-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-response" + } + ] } }, "additionalProperties": false @@ -2641,10 +2817,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-collection-document" + } + ] }, "data": { "type": "array", @@ -2667,17 +2851,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-attendant-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/flight-attendant-attributes-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-attributes-in-patch-request" + } + ] }, "relationships": { - "$ref": "#/components/schemas/flight-attendant-relationships-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-relationships-in-patch-request" + } + ] } }, "additionalProperties": false @@ -2689,13 +2885,25 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-attendant-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-resource-type" + } + ] }, "attributes": { - "$ref": "#/components/schemas/flight-attendant-attributes-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-attributes-in-post-request" + } + ] }, "relationships": { - "$ref": "#/components/schemas/flight-attendant-relationships-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-relationships-in-post-request" + } + ] } }, "additionalProperties": false @@ -2709,20 +2917,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-attendant-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/flight-attendant-attributes-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-attributes-in-response" + } + ] }, "relationships": { - "$ref": "#/components/schemas/flight-attendant-relationships-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-relationships-in-response" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-object" + } + ] }, "meta": { "type": "object", @@ -2739,7 +2963,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-attendant-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-resource-type" + } + ] }, "id": { "minLength": 1, @@ -2756,10 +2984,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + } + ] }, "data": { "type": "array", @@ -2782,13 +3018,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-document" + } + ] }, "data": { - "$ref": "#/components/schemas/flight-attendant-identifier" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-identifier" + } + ] }, "meta": { "type": "object", @@ -2804,7 +3052,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/flight-attendant-data-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-data-in-patch-request" + } + ] } }, "additionalProperties": false @@ -2816,7 +3068,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/flight-attendant-data-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-data-in-post-request" + } + ] } }, "additionalProperties": false @@ -2829,13 +3085,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "$ref": "#/components/schemas/flight-attendant-data-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-data-in-response" + } + ] }, "meta": { "type": "object", @@ -2848,10 +3116,18 @@ "type": "object", "properties": { "scheduled-for-flights": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] }, "purser-on-flights": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } }, "additionalProperties": false @@ -2860,10 +3136,18 @@ "type": "object", "properties": { "scheduled-for-flights": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] }, "purser-on-flights": { - "$ref": "#/components/schemas/to-many-flight-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-request" + } + ] } }, "additionalProperties": false @@ -2872,10 +3156,18 @@ "type": "object", "properties": { "scheduled-for-flights": { - "$ref": "#/components/schemas/to-many-flight-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-response" + } + ] }, "purser-on-flights": { - "$ref": "#/components/schemas/to-many-flight-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-in-response" + } + ] } }, "additionalProperties": false @@ -2894,13 +3186,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "$ref": "#/components/schemas/flight-attendant-data-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-data-in-response" + } + ] }, "meta": { "type": "object", @@ -2922,7 +3226,11 @@ "nullable": true }, "operated-by": { - "$ref": "#/components/schemas/airline" + "allOf": [ + { + "$ref": "#/components/schemas/airline" + } + ] } }, "additionalProperties": false @@ -2944,7 +3252,11 @@ "nullable": true }, "operated-by": { - "$ref": "#/components/schemas/airline" + "allOf": [ + { + "$ref": "#/components/schemas/airline" + } + ] }, "departs-at": { "type": "string", @@ -2973,10 +3285,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-collection-document" + } + ] }, "data": { "type": "array", @@ -2999,17 +3319,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/flight-attributes-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attributes-in-patch-request" + } + ] }, "relationships": { - "$ref": "#/components/schemas/flight-relationships-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-relationships-in-patch-request" + } + ] } }, "additionalProperties": false @@ -3021,10 +3353,18 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-resource-type" + } + ] }, "relationships": { - "$ref": "#/components/schemas/flight-relationships-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-relationships-in-post-request" + } + ] } }, "additionalProperties": false @@ -3038,20 +3378,36 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/flight-attributes-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attributes-in-response" + } + ] }, "relationships": { - "$ref": "#/components/schemas/flight-relationships-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-relationships-in-response" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-object" + } + ] }, "meta": { "type": "object", @@ -3068,7 +3424,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/flight-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/flight-resource-type" + } + ] }, "id": { "minLength": 1, @@ -3085,10 +3445,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + } + ] }, "data": { "type": "array", @@ -3110,7 +3478,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/flight-data-in-patch-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-data-in-patch-request" + } + ] } }, "additionalProperties": false @@ -3122,7 +3494,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/flight-data-in-post-request" + "allOf": [ + { + "$ref": "#/components/schemas/flight-data-in-post-request" + } + ] } }, "additionalProperties": false @@ -3135,13 +3511,25 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "$ref": "#/components/schemas/flight-data-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/flight-data-in-response" + } + ] }, "meta": { "type": "object", @@ -3154,16 +3542,32 @@ "type": "object", "properties": { "cabin-crew-members": { - "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + } + ] }, "purser": { - "$ref": "#/components/schemas/to-one-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-one-flight-attendant-in-request" + } + ] }, "backup-purser": { - "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" + } + ] }, "passengers": { - "$ref": "#/components/schemas/to-many-passenger-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-passenger-in-request" + } + ] } }, "additionalProperties": false @@ -3175,16 +3579,32 @@ "type": "object", "properties": { "cabin-crew-members": { - "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-attendant-in-request" + } + ] }, "purser": { - "$ref": "#/components/schemas/to-one-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-one-flight-attendant-in-request" + } + ] }, "backup-purser": { - "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-request" + } + ] }, "passengers": { - "$ref": "#/components/schemas/to-many-passenger-in-request" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-passenger-in-request" + } + ] } }, "additionalProperties": false @@ -3196,16 +3616,32 @@ "type": "object", "properties": { "cabin-crew-members": { - "$ref": "#/components/schemas/to-many-flight-attendant-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-flight-attendant-in-response" + } + ] }, "purser": { - "$ref": "#/components/schemas/to-one-flight-attendant-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-one-flight-attendant-in-response" + } + ] }, "backup-purser": { - "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/nullable-to-one-flight-attendant-in-response" + } + ] }, "passengers": { - "$ref": "#/components/schemas/to-many-passenger-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/to-many-passenger-in-response" + } + ] } }, "additionalProperties": false @@ -3374,29 +3810,6 @@ }, "additionalProperties": false }, - "null-value": { - "not": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "boolean" - }, - { - "type": "object" - }, - { - "type": "array" - } - ], - "items": { } - }, - "nullable": true - }, "nullable-flight-attendant-identifier-response-document": { "required": [ "data", @@ -3405,20 +3818,26 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-document" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/flight-attendant-identifier" - }, - { - "$ref": "#/components/schemas/null-value" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -3435,20 +3854,26 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-document" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/flight-attendant-data-in-response" - }, - { - "$ref": "#/components/schemas/null-value" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -3464,14 +3889,12 @@ "type": "object", "properties": { "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/flight-attendant-identifier" - }, - { - "$ref": "#/components/schemas/null-value" } - ] + ], + "nullable": true } }, "additionalProperties": false @@ -3483,17 +3906,19 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { - "oneOf": [ + "allOf": [ { "$ref": "#/components/schemas/flight-attendant-identifier" - }, - { - "$ref": "#/components/schemas/null-value" } - ] + ], + "nullable": true }, "meta": { "type": "object", @@ -3510,7 +3935,11 @@ "nullable": true }, "cabin-area": { - "$ref": "#/components/schemas/cabin-area" + "allOf": [ + { + "$ref": "#/components/schemas/cabin-area" + } + ] } }, "additionalProperties": false @@ -3523,10 +3952,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-collection-document" + } + ] }, "data": { "type": "array", @@ -3550,17 +3987,29 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/passenger-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/passenger-resource-type" + } + ] }, "id": { "minLength": 1, "type": "string" }, "attributes": { - "$ref": "#/components/schemas/passenger-attributes-in-response" + "allOf": [ + { + "$ref": "#/components/schemas/passenger-attributes-in-response" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-object" + } + ] }, "meta": { "type": "object", @@ -3577,7 +4026,11 @@ "type": "object", "properties": { "type": { - "$ref": "#/components/schemas/passenger-resource-type" + "allOf": [ + { + "$ref": "#/components/schemas/passenger-resource-type" + } + ] }, "id": { "minLength": 1, @@ -3594,10 +4047,18 @@ "type": "object", "properties": { "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" + "allOf": [ + { + "$ref": "#/components/schemas/jsonapi-object" + } + ] }, "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + } + ] }, "data": { "type": "array", @@ -3640,7 +4101,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { "type": "array", @@ -3677,7 +4142,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { "type": "array", @@ -3714,7 +4183,11 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { "type": "array", @@ -3736,7 +4209,11 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/flight-attendant-identifier" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-identifier" + } + ] } }, "additionalProperties": false @@ -3748,10 +4225,18 @@ "type": "object", "properties": { "links": { - "$ref": "#/components/schemas/links-in-relationship-object" + "allOf": [ + { + "$ref": "#/components/schemas/links-in-relationship-object" + } + ] }, "data": { - "$ref": "#/components/schemas/flight-attendant-identifier" + "allOf": [ + { + "$ref": "#/components/schemas/flight-attendant-identifier" + } + ] }, "meta": { "type": "object", diff --git a/test/OpenApiTests/NamingConventions/CamelCase/CamelCaseTests.cs b/test/OpenApiTests/NamingConventions/CamelCase/CamelCaseTests.cs index cd786b26b8..9b623ceb16 100644 --- a/test/OpenApiTests/NamingConventions/CamelCase/CamelCaseTests.cs +++ b/test/OpenApiTests/NamingConventions/CamelCase/CamelCaseTests.cs @@ -43,9 +43,9 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - propertiesElement.Should().ContainPath("jsonapi.$ref").ShouldBeSchemaReferenceId("jsonapiObject"); + propertiesElement.Should().ContainPath("jsonapi.allOf[0].$ref").ShouldBeSchemaReferenceId("jsonapiObject"); - linksInResourceCollectionDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInResourceCollectionDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("linksInResourceCollectionDocument").SchemaReferenceId; resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.items.$ref").ShouldBeSchemaReferenceId("supermarketDataInResponse") @@ -69,16 +69,16 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() schemasElement.Should().ContainPath($"{resourceDataSchemaRefId}.properties").With(propertiesElement => { - linksInResourceObjectSchemaRefId = propertiesElement.Should().ContainPath("links.$ref").ShouldBeSchemaReferenceId("linksInResourceObject") - .SchemaReferenceId; + linksInResourceObjectSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") + .ShouldBeSchemaReferenceId("linksInResourceObject").SchemaReferenceId; - primaryResourceTypeSchemaRefId = propertiesElement.Should().ContainPath("type.$ref").ShouldBeSchemaReferenceId("supermarketResourceType") - .SchemaReferenceId; + primaryResourceTypeSchemaRefId = propertiesElement.Should().ContainPath("type.allOf[0].$ref") + .ShouldBeSchemaReferenceId("supermarketResourceType").SchemaReferenceId; - resourceAttributesInResponseSchemaRefId = propertiesElement.Should().ContainPath("attributes.$ref") + resourceAttributesInResponseSchemaRefId = propertiesElement.Should().ContainPath("attributes.allOf[0].$ref") .ShouldBeSchemaReferenceId("supermarketAttributesInResponse").SchemaReferenceId; - resourceRelationshipInResponseSchemaRefId = propertiesElement.Should().ContainPath("relationships.$ref") + resourceRelationshipInResponseSchemaRefId = propertiesElement.Should().ContainPath("relationships.allOf[0].$ref") .ShouldBeSchemaReferenceId("supermarketRelationshipsInResponse").SchemaReferenceId; }); @@ -96,7 +96,7 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() { propertiesElement.Should().ContainProperty("nameOfCity"); propertiesElement.Should().ContainProperty("kind"); - propertiesElement.Should().ContainPath("kind.$ref").ShouldBeSchemaReferenceId("supermarketType"); + propertiesElement.Should().ContainPath("kind.allOf[0].$ref").ShouldBeSchemaReferenceId("supermarketType"); }); string? nullableToOneResourceResponseDataSchemaRefId = null; @@ -105,13 +105,13 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() { propertiesElement.Should().ContainProperty("storeManager"); - propertiesElement.Should().ContainPath("storeManager.$ref").ShouldBeSchemaReferenceId("toOneStaffMemberInResponse"); + propertiesElement.Should().ContainPath("storeManager.allOf[0].$ref").ShouldBeSchemaReferenceId("toOneStaffMemberInResponse"); - nullableToOneResourceResponseDataSchemaRefId = propertiesElement.Should().ContainPath("backupStoreManager.$ref") + nullableToOneResourceResponseDataSchemaRefId = propertiesElement.Should().ContainPath("backupStoreManager.allOf[0].$ref") .ShouldBeSchemaReferenceId("nullableToOneStaffMemberInResponse").SchemaReferenceId; propertiesElement.Should().ContainProperty("cashiers"); - propertiesElement.Should().ContainPath("cashiers.$ref").ShouldBeSchemaReferenceId("toManyStaffMemberInResponse"); + propertiesElement.Should().ContainPath("cashiers.allOf[0].$ref").ShouldBeSchemaReferenceId("toManyStaffMemberInResponse"); }); string? linksInRelationshipObjectSchemaRefId = null; @@ -119,13 +119,11 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() schemasElement.Should().ContainPath($"{nullableToOneResourceResponseDataSchemaRefId}.properties").With(propertiesElement => { - linksInRelationshipObjectSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInRelationshipObjectSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("linksInRelationshipObject").SchemaReferenceId; - relatedResourceIdentifierSchemaRefId = propertiesElement.Should().ContainPath("data.oneOf[0].$ref") + relatedResourceIdentifierSchemaRefId = propertiesElement.Should().ContainPath("data.allOf[0].$ref") .ShouldBeSchemaReferenceId("staffMemberIdentifier").SchemaReferenceId; - - propertiesElement.Should().ContainPath("data.oneOf[1].$ref").ShouldBeSchemaReferenceId("nullValue"); }); schemasElement.Should().ContainPath($"{linksInRelationshipObjectSchemaRefId}.properties").With(propertiesElement => @@ -138,8 +136,8 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() schemasElement.Should().ContainPath($"{relatedResourceIdentifierSchemaRefId}.properties").With(propertiesElement => { - relatedResourceTypeSchemaRefId = propertiesElement.Should().ContainPath("type.$ref").ShouldBeSchemaReferenceId("staffMemberResourceType") - .SchemaReferenceId; + relatedResourceTypeSchemaRefId = propertiesElement.Should().ContainPath("type.allOf[0].$ref") + .ShouldBeSchemaReferenceId("staffMemberResourceType").SchemaReferenceId; }); schemasElement.Should().ContainPath($"{relatedResourceTypeSchemaRefId}.enum[0]").ShouldBeSchemaReferenceId("staffMembers"); @@ -172,8 +170,8 @@ public async Task Casing_convention_is_applied_to_GetSingle_endpoint() schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - linksInResourceDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.$ref").ShouldBeSchemaReferenceId("linksInResourceDocument") - .SchemaReferenceId; + linksInResourceDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") + .ShouldBeSchemaReferenceId("linksInResourceDocument").SchemaReferenceId; }); schemasElement.Should().ContainPath($"{linksInResourceDocumentSchemaRefId}.properties").With(propertiesElement => @@ -210,13 +208,13 @@ public async Task Casing_convention_is_applied_to_GetSecondary_endpoint_with_sin schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.$ref").ShouldBeSchemaReferenceId("staffMemberDataInResponse") + resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.allOf[0].$ref").ShouldBeSchemaReferenceId("staffMemberDataInResponse") .SchemaReferenceId; }); schemasElement.Should().ContainPath($"{resourceDataSchemaRefId}.properties").With(propertiesElement => { - propertiesElement.Should().ContainPath("attributes.$ref").ShouldBeSchemaReferenceId("staffMemberAttributesInResponse"); + propertiesElement.Should().ContainPath("attributes.allOf[0].$ref").ShouldBeSchemaReferenceId("staffMemberAttributesInResponse"); }); }); } @@ -285,7 +283,7 @@ public async Task Casing_convention_is_applied_to_GetRelationship_endpoint_with_ schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - linksInResourceIdentifierDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInResourceIdentifierDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("linksInResourceIdentifierDocument").SchemaReferenceId; }); @@ -343,7 +341,7 @@ public async Task Casing_convention_is_applied_to_GetRelationship_endpoint_with_ schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - linksInResourceIdentifierCollectionDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInResourceIdentifierCollectionDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("linksInResourceIdentifierCollectionDocument").SchemaReferenceId; }); @@ -376,7 +374,7 @@ public async Task Casing_convention_is_applied_to_Post_endpoint() operationElement.Should().Be("postSupermarket"); }); - documentSchemaRefId = getElement.Should().ContainPath("requestBody.content['application/vnd.api+json'].schema.$ref") + documentSchemaRefId = getElement.Should().ContainPath("requestBody.content['application/vnd.api+json'].schema.allOf[0].$ref") .ShouldBeSchemaReferenceId("supermarketPostRequestDocument").SchemaReferenceId; }); @@ -386,7 +384,7 @@ public async Task Casing_convention_is_applied_to_Post_endpoint() schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.$ref").ShouldBeSchemaReferenceId("supermarketDataInPostRequest") + resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.allOf[0].$ref").ShouldBeSchemaReferenceId("supermarketDataInPostRequest") .SchemaReferenceId; }); @@ -394,22 +392,22 @@ public async Task Casing_convention_is_applied_to_Post_endpoint() schemasElement.Should().ContainPath($"{resourceDataSchemaRefId}.properties").With(propertiesElement => { - propertiesElement.Should().ContainPath("attributes.$ref").ShouldBeSchemaReferenceId("supermarketAttributesInPostRequest"); + propertiesElement.Should().ContainPath("attributes.allOf[0].$ref").ShouldBeSchemaReferenceId("supermarketAttributesInPostRequest"); - resourceRelationshipInPostRequestSchemaRefId = propertiesElement.Should().ContainPath("relationships.$ref") + resourceRelationshipInPostRequestSchemaRefId = propertiesElement.Should().ContainPath("relationships.allOf[0].$ref") .ShouldBeSchemaReferenceId("supermarketRelationshipsInPostRequest").SchemaReferenceId; }); schemasElement.Should().ContainPath($"{resourceRelationshipInPostRequestSchemaRefId}.properties").With(propertiesElement => { propertiesElement.Should().ContainProperty("storeManager"); - propertiesElement.Should().ContainPath("storeManager.$ref").ShouldBeSchemaReferenceId("toOneStaffMemberInRequest"); + propertiesElement.Should().ContainPath("storeManager.allOf[0].$ref").ShouldBeSchemaReferenceId("toOneStaffMemberInRequest"); propertiesElement.Should().ContainProperty("backupStoreManager"); - propertiesElement.Should().ContainPath("backupStoreManager.$ref").ShouldBeSchemaReferenceId("nullableToOneStaffMemberInRequest"); + propertiesElement.Should().ContainPath("backupStoreManager.allOf[0].$ref").ShouldBeSchemaReferenceId("nullableToOneStaffMemberInRequest"); propertiesElement.Should().ContainProperty("cashiers"); - propertiesElement.Should().ContainPath("cashiers.$ref").ShouldBeSchemaReferenceId("toManyStaffMemberInRequest"); + propertiesElement.Should().ContainPath("cashiers.allOf[0].$ref").ShouldBeSchemaReferenceId("toManyStaffMemberInRequest"); }); }); } @@ -446,7 +444,7 @@ public async Task Casing_convention_is_applied_to_Patch_endpoint() operationElement.Should().Be("patchSupermarket"); }); - documentSchemaRefId = getElement.Should().ContainPath("requestBody.content['application/vnd.api+json'].schema.$ref") + documentSchemaRefId = getElement.Should().ContainPath("requestBody.content['application/vnd.api+json'].schema.allOf[0].$ref") .ShouldBeSchemaReferenceId("supermarketPatchRequestDocument").SchemaReferenceId; }); @@ -456,14 +454,14 @@ public async Task Casing_convention_is_applied_to_Patch_endpoint() schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.$ref").ShouldBeSchemaReferenceId("supermarketDataInPatchRequest") - .SchemaReferenceId; + resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.allOf[0].$ref") + .ShouldBeSchemaReferenceId("supermarketDataInPatchRequest").SchemaReferenceId; }); schemasElement.Should().ContainPath($"{resourceDataSchemaRefId}.properties").With(propertiesElement => { - propertiesElement.Should().ContainPath("attributes.$ref").ShouldBeSchemaReferenceId("supermarketAttributesInPatchRequest"); - propertiesElement.Should().ContainPath("relationships.$ref").ShouldBeSchemaReferenceId("supermarketRelationshipsInPatchRequest"); + propertiesElement.Should().ContainPath("attributes.allOf[0].$ref").ShouldBeSchemaReferenceId("supermarketAttributesInPatchRequest"); + propertiesElement.Should().ContainPath("relationships.allOf[0].$ref").ShouldBeSchemaReferenceId("supermarketRelationshipsInPatchRequest"); }); }); } diff --git a/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseTests.cs b/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseTests.cs index 628576679b..78521a15ee 100644 --- a/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseTests.cs +++ b/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseTests.cs @@ -43,9 +43,9 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - propertiesElement.Should().ContainPath("jsonapi.$ref").ShouldBeSchemaReferenceId("jsonapi-object"); + propertiesElement.Should().ContainPath("jsonapi.allOf[0].$ref").ShouldBeSchemaReferenceId("jsonapi-object"); - linksInResourceCollectionDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInResourceCollectionDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("links-in-resource-collection-document").SchemaReferenceId; resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.items.$ref").ShouldBeSchemaReferenceId("supermarket-data-in-response") @@ -69,16 +69,16 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() schemasElement.Should().ContainPath($"{resourceDataSchemaRefId}.properties").With(propertiesElement => { - linksInResourceObjectSchemaRefId = propertiesElement.Should().ContainPath("links.$ref").ShouldBeSchemaReferenceId("links-in-resource-object") - .SchemaReferenceId; + linksInResourceObjectSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") + .ShouldBeSchemaReferenceId("links-in-resource-object").SchemaReferenceId; - primaryResourceTypeSchemaRefId = propertiesElement.Should().ContainPath("type.$ref").ShouldBeSchemaReferenceId("supermarket-resource-type") - .SchemaReferenceId; + primaryResourceTypeSchemaRefId = propertiesElement.Should().ContainPath("type.allOf[0].$ref") + .ShouldBeSchemaReferenceId("supermarket-resource-type").SchemaReferenceId; - resourceAttributesInResponseSchemaRefId = propertiesElement.Should().ContainPath("attributes.$ref") + resourceAttributesInResponseSchemaRefId = propertiesElement.Should().ContainPath("attributes.allOf[0].$ref") .ShouldBeSchemaReferenceId("supermarket-attributes-in-response").SchemaReferenceId; - resourceRelationshipInResponseSchemaRefId = propertiesElement.Should().ContainPath("relationships.$ref") + resourceRelationshipInResponseSchemaRefId = propertiesElement.Should().ContainPath("relationships.allOf[0].$ref") .ShouldBeSchemaReferenceId("supermarket-relationships-in-response").SchemaReferenceId; }); @@ -96,7 +96,7 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() { propertiesElement.Should().ContainProperty("name-of-city"); propertiesElement.Should().ContainProperty("kind"); - propertiesElement.Should().ContainPath("kind.$ref").ShouldBeSchemaReferenceId("supermarket-type"); + propertiesElement.Should().ContainPath("kind.allOf[0].$ref").ShouldBeSchemaReferenceId("supermarket-type"); }); string? nullableToOneResourceResponseDataSchemaRefId = null; @@ -105,13 +105,13 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() { propertiesElement.Should().ContainProperty("store-manager"); - propertiesElement.Should().ContainPath("store-manager.$ref").ShouldBeSchemaReferenceId("to-one-staff-member-in-response"); + propertiesElement.Should().ContainPath("store-manager.allOf[0].$ref").ShouldBeSchemaReferenceId("to-one-staff-member-in-response"); - nullableToOneResourceResponseDataSchemaRefId = propertiesElement.Should().ContainPath("backup-store-manager.$ref") + nullableToOneResourceResponseDataSchemaRefId = propertiesElement.Should().ContainPath("backup-store-manager.allOf[0].$ref") .ShouldBeSchemaReferenceId("nullable-to-one-staff-member-in-response").SchemaReferenceId; propertiesElement.Should().ContainProperty("cashiers"); - propertiesElement.Should().ContainPath("cashiers.$ref").ShouldBeSchemaReferenceId("to-many-staff-member-in-response"); + propertiesElement.Should().ContainPath("cashiers.allOf[0].$ref").ShouldBeSchemaReferenceId("to-many-staff-member-in-response"); }); string? linksInRelationshipObjectSchemaRefId = null; @@ -119,13 +119,11 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() schemasElement.Should().ContainPath($"{nullableToOneResourceResponseDataSchemaRefId}.properties").With(propertiesElement => { - linksInRelationshipObjectSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInRelationshipObjectSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("links-in-relationship-object").SchemaReferenceId; - relatedResourceIdentifierSchemaRefId = propertiesElement.Should().ContainPath("data.oneOf[0].$ref") + relatedResourceIdentifierSchemaRefId = propertiesElement.Should().ContainPath("data.allOf[0].$ref") .ShouldBeSchemaReferenceId("staff-member-identifier").SchemaReferenceId; - - propertiesElement.Should().ContainPath("data.oneOf[1].$ref").ShouldBeSchemaReferenceId("null-value"); }); schemasElement.Should().ContainPath($"{linksInRelationshipObjectSchemaRefId}.properties").With(propertiesElement => @@ -138,8 +136,8 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() schemasElement.Should().ContainPath($"{relatedResourceIdentifierSchemaRefId}.properties").With(propertiesElement => { - relatedResourceTypeSchemaRefId = propertiesElement.Should().ContainPath("type.$ref").ShouldBeSchemaReferenceId("staff-member-resource-type") - .SchemaReferenceId; + relatedResourceTypeSchemaRefId = propertiesElement.Should().ContainPath("type.allOf[0].$ref") + .ShouldBeSchemaReferenceId("staff-member-resource-type").SchemaReferenceId; }); schemasElement.Should().ContainPath($"{relatedResourceTypeSchemaRefId}.enum[0]").ShouldBeSchemaReferenceId("staff-members"); @@ -172,7 +170,7 @@ public async Task Casing_convention_is_applied_to_GetSingle_endpoint() schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - linksInResourceDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInResourceDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("links-in-resource-document").SchemaReferenceId; }); @@ -210,13 +208,13 @@ public async Task Casing_convention_is_applied_to_GetSecondary_endpoint_with_sin schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.$ref").ShouldBeSchemaReferenceId("staff-member-data-in-response") - .SchemaReferenceId; + resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.allOf[0].$ref") + .ShouldBeSchemaReferenceId("staff-member-data-in-response").SchemaReferenceId; }); schemasElement.Should().ContainPath($"{resourceDataSchemaRefId}.properties").With(propertiesElement => { - propertiesElement.Should().ContainPath("attributes.$ref").ShouldBeSchemaReferenceId("staff-member-attributes-in-response"); + propertiesElement.Should().ContainPath("attributes.allOf[0].$ref").ShouldBeSchemaReferenceId("staff-member-attributes-in-response"); }); }); } @@ -285,7 +283,7 @@ public async Task Casing_convention_is_applied_to_GetRelationship_endpoint_with_ schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - linksInResourceIdentifierDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInResourceIdentifierDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("links-in-resource-identifier-document").SchemaReferenceId; }); @@ -343,7 +341,7 @@ public async Task Casing_convention_is_applied_to_GetRelationship_endpoint_with_ schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - linksInResourceIdentifierCollectionDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInResourceIdentifierCollectionDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("links-in-resource-identifier-collection-document").SchemaReferenceId; }); @@ -376,7 +374,7 @@ public async Task Casing_convention_is_applied_to_Post_endpoint() operationElement.Should().Be("post-supermarket"); }); - documentSchemaRefId = getElement.Should().ContainPath("requestBody.content['application/vnd.api+json'].schema.$ref") + documentSchemaRefId = getElement.Should().ContainPath("requestBody.content['application/vnd.api+json'].schema.allOf[0].$ref") .ShouldBeSchemaReferenceId("supermarket-post-request-document").SchemaReferenceId; }); @@ -386,30 +384,32 @@ public async Task Casing_convention_is_applied_to_Post_endpoint() schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.$ref").ShouldBeSchemaReferenceId("supermarket-data-in-post-request") - .SchemaReferenceId; + resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.allOf[0].$ref") + .ShouldBeSchemaReferenceId("supermarket-data-in-post-request").SchemaReferenceId; }); string? resourceRelationshipInPostRequestSchemaRefId = null; schemasElement.Should().ContainPath($"{resourceDataSchemaRefId}.properties").With(propertiesElement => { - propertiesElement.Should().ContainPath("attributes.$ref").ShouldBeSchemaReferenceId("supermarket-attributes-in-post-request"); + propertiesElement.Should().ContainPath("attributes.allOf[0].$ref").ShouldBeSchemaReferenceId("supermarket-attributes-in-post-request"); - resourceRelationshipInPostRequestSchemaRefId = propertiesElement.Should().ContainPath("relationships.$ref") + resourceRelationshipInPostRequestSchemaRefId = propertiesElement.Should().ContainPath("relationships.allOf[0].$ref") .ShouldBeSchemaReferenceId("supermarket-relationships-in-post-request").SchemaReferenceId; }); schemasElement.Should().ContainPath($"{resourceRelationshipInPostRequestSchemaRefId}.properties").With(propertiesElement => { propertiesElement.Should().ContainProperty("store-manager"); - propertiesElement.Should().ContainPath("store-manager.$ref").ShouldBeSchemaReferenceId("to-one-staff-member-in-request"); + propertiesElement.Should().ContainPath("store-manager.allOf[0].$ref").ShouldBeSchemaReferenceId("to-one-staff-member-in-request"); propertiesElement.Should().ContainProperty("backup-store-manager"); - propertiesElement.Should().ContainPath("backup-store-manager.$ref").ShouldBeSchemaReferenceId("nullable-to-one-staff-member-in-request"); + + propertiesElement.Should().ContainPath("backup-store-manager.allOf[0].$ref") + .ShouldBeSchemaReferenceId("nullable-to-one-staff-member-in-request"); propertiesElement.Should().ContainProperty("cashiers"); - propertiesElement.Should().ContainPath("cashiers.$ref").ShouldBeSchemaReferenceId("to-many-staff-member-in-request"); + propertiesElement.Should().ContainPath("cashiers.allOf[0].$ref").ShouldBeSchemaReferenceId("to-many-staff-member-in-request"); }); }); } @@ -446,7 +446,7 @@ public async Task Casing_convention_is_applied_to_Patch_endpoint() operationElement.Should().Be("patch-supermarket"); }); - documentSchemaRefId = getElement.Should().ContainPath("requestBody.content['application/vnd.api+json'].schema.$ref") + documentSchemaRefId = getElement.Should().ContainPath("requestBody.content['application/vnd.api+json'].schema.allOf[0].$ref") .ShouldBeSchemaReferenceId("supermarket-patch-request-document").SchemaReferenceId; }); @@ -456,14 +456,14 @@ public async Task Casing_convention_is_applied_to_Patch_endpoint() schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.$ref").ShouldBeSchemaReferenceId("supermarket-data-in-patch-request") - .SchemaReferenceId; + resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.allOf[0].$ref") + .ShouldBeSchemaReferenceId("supermarket-data-in-patch-request").SchemaReferenceId; }); schemasElement.Should().ContainPath($"{resourceDataSchemaRefId}.properties").With(propertiesElement => { - propertiesElement.Should().ContainPath("attributes.$ref").ShouldBeSchemaReferenceId("supermarket-attributes-in-patch-request"); - propertiesElement.Should().ContainPath("relationships.$ref").ShouldBeSchemaReferenceId("supermarket-relationships-in-patch-request"); + propertiesElement.Should().ContainPath("attributes.allOf[0].$ref").ShouldBeSchemaReferenceId("supermarket-attributes-in-patch-request"); + propertiesElement.Should().ContainPath("relationships.allOf[0].$ref").ShouldBeSchemaReferenceId("supermarket-relationships-in-patch-request"); }); }); } diff --git a/test/OpenApiTests/NamingConventions/PascalCase/PascalCaseTests.cs b/test/OpenApiTests/NamingConventions/PascalCase/PascalCaseTests.cs index cd04ad8565..fe801a500f 100644 --- a/test/OpenApiTests/NamingConventions/PascalCase/PascalCaseTests.cs +++ b/test/OpenApiTests/NamingConventions/PascalCase/PascalCaseTests.cs @@ -44,9 +44,9 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - propertiesElement.Should().ContainPath("jsonapi.$ref").ShouldBeSchemaReferenceId("JsonapiObject"); + propertiesElement.Should().ContainPath("jsonapi.allOf[0].$ref").ShouldBeSchemaReferenceId("JsonapiObject"); - linksInResourceCollectionDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInResourceCollectionDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("LinksInResourceCollectionDocument").SchemaReferenceId; resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.items.$ref").ShouldBeSchemaReferenceId("SupermarketDataInResponse") @@ -70,16 +70,16 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() schemasElement.Should().ContainPath($"{resourceDataSchemaRefId}.properties").With(propertiesElement => { - linksInResourceObjectSchemaRefId = propertiesElement.Should().ContainPath("links.$ref").ShouldBeSchemaReferenceId("LinksInResourceObject") - .SchemaReferenceId; + linksInResourceObjectSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") + .ShouldBeSchemaReferenceId("LinksInResourceObject").SchemaReferenceId; - primaryResourceTypeSchemaRefId = propertiesElement.Should().ContainPath("type.$ref").ShouldBeSchemaReferenceId("SupermarketResourceType") - .SchemaReferenceId; + primaryResourceTypeSchemaRefId = propertiesElement.Should().ContainPath("type.allOf[0].$ref") + .ShouldBeSchemaReferenceId("SupermarketResourceType").SchemaReferenceId; - resourceAttributesInResponseSchemaRefId = propertiesElement.Should().ContainPath("attributes.$ref") + resourceAttributesInResponseSchemaRefId = propertiesElement.Should().ContainPath("attributes.allOf[0].$ref") .ShouldBeSchemaReferenceId("SupermarketAttributesInResponse").SchemaReferenceId; - resourceRelationshipInResponseSchemaRefId = propertiesElement.Should().ContainPath("relationships.$ref") + resourceRelationshipInResponseSchemaRefId = propertiesElement.Should().ContainPath("relationships.allOf[0].$ref") .ShouldBeSchemaReferenceId("SupermarketRelationshipsInResponse").SchemaReferenceId; }); @@ -97,7 +97,7 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() { propertiesElement.Should().ContainProperty("NameOfCity"); propertiesElement.Should().ContainProperty("Kind"); - propertiesElement.Should().ContainPath("Kind.$ref").ShouldBeSchemaReferenceId("SupermarketType"); + propertiesElement.Should().ContainPath("Kind.allOf[0].$ref").ShouldBeSchemaReferenceId("SupermarketType"); }); string? nullableToOneResourceResponseDataSchemaRefId = null; @@ -106,13 +106,13 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() { propertiesElement.Should().ContainProperty("StoreManager"); - propertiesElement.Should().ContainPath("StoreManager.$ref").ShouldBeSchemaReferenceId("ToOneStaffMemberInResponse"); + propertiesElement.Should().ContainPath("StoreManager.allOf[0].$ref").ShouldBeSchemaReferenceId("ToOneStaffMemberInResponse"); - nullableToOneResourceResponseDataSchemaRefId = propertiesElement.Should().ContainPath("BackupStoreManager.$ref") + nullableToOneResourceResponseDataSchemaRefId = propertiesElement.Should().ContainPath("BackupStoreManager.allOf[0].$ref") .ShouldBeSchemaReferenceId("NullableToOneStaffMemberInResponse").SchemaReferenceId; propertiesElement.Should().ContainProperty("Cashiers"); - propertiesElement.Should().ContainPath("Cashiers.$ref").ShouldBeSchemaReferenceId("ToManyStaffMemberInResponse"); + propertiesElement.Should().ContainPath("Cashiers.allOf[0].$ref").ShouldBeSchemaReferenceId("ToManyStaffMemberInResponse"); }); string? linksInRelationshipObjectSchemaRefId = null; @@ -120,13 +120,11 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() schemasElement.Should().ContainPath($"{nullableToOneResourceResponseDataSchemaRefId}.properties").With(propertiesElement => { - linksInRelationshipObjectSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInRelationshipObjectSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("LinksInRelationshipObject").SchemaReferenceId; - relatedResourceIdentifierSchemaRefId = propertiesElement.Should().ContainPath("data.oneOf[0].$ref") + relatedResourceIdentifierSchemaRefId = propertiesElement.Should().ContainPath("data.allOf[0].$ref") .ShouldBeSchemaReferenceId("StaffMemberIdentifier").SchemaReferenceId; - - propertiesElement.Should().ContainPath("data.oneOf[1].$ref").ShouldBeSchemaReferenceId("NullValue"); }); schemasElement.Should().ContainPath($"{linksInRelationshipObjectSchemaRefId}.properties").With(propertiesElement => @@ -139,8 +137,8 @@ public async Task Casing_convention_is_applied_to_GetCollection_endpoint() schemasElement.Should().ContainPath($"{relatedResourceIdentifierSchemaRefId}.properties").With(propertiesElement => { - relatedResourceTypeSchemaRefId = propertiesElement.Should().ContainPath("type.$ref").ShouldBeSchemaReferenceId("StaffMemberResourceType") - .SchemaReferenceId; + relatedResourceTypeSchemaRefId = propertiesElement.Should().ContainPath("type.allOf[0].$ref") + .ShouldBeSchemaReferenceId("StaffMemberResourceType").SchemaReferenceId; }); schemasElement.Should().ContainPath($"{relatedResourceTypeSchemaRefId}.enum[0]").ShouldBeSchemaReferenceId("StaffMembers"); @@ -173,8 +171,8 @@ public async Task Casing_convention_is_applied_to_GetSingle_endpoint() schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - linksInResourceDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.$ref").ShouldBeSchemaReferenceId("LinksInResourceDocument") - .SchemaReferenceId; + linksInResourceDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") + .ShouldBeSchemaReferenceId("LinksInResourceDocument").SchemaReferenceId; }); schemasElement.Should().ContainPath($"{linksInResourceDocumentSchemaRefId}.properties").With(propertiesElement => @@ -211,13 +209,13 @@ public async Task Casing_convention_is_applied_to_GetSecondary_endpoint_with_sin schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.$ref").ShouldBeSchemaReferenceId("StaffMemberDataInResponse") + resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.allOf[0].$ref").ShouldBeSchemaReferenceId("StaffMemberDataInResponse") .SchemaReferenceId; }); schemasElement.Should().ContainPath($"{resourceDataSchemaRefId}.properties").With(propertiesElement => { - propertiesElement.Should().ContainPath("attributes.$ref").ShouldBeSchemaReferenceId("StaffMemberAttributesInResponse"); + propertiesElement.Should().ContainPath("attributes.allOf[0].$ref").ShouldBeSchemaReferenceId("StaffMemberAttributesInResponse"); }); }); } @@ -286,7 +284,7 @@ public async Task Casing_convention_is_applied_to_GetRelationship_endpoint_with_ schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - linksInResourceIdentifierDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInResourceIdentifierDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("LinksInResourceIdentifierDocument").SchemaReferenceId; }); @@ -344,7 +342,7 @@ public async Task Casing_convention_is_applied_to_GetRelationship_endpoint_with_ schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - linksInResourceIdentifierCollectionDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.$ref") + linksInResourceIdentifierCollectionDocumentSchemaRefId = propertiesElement.Should().ContainPath("links.allOf[0].$ref") .ShouldBeSchemaReferenceId("LinksInResourceIdentifierCollectionDocument").SchemaReferenceId; }); @@ -377,7 +375,7 @@ public async Task Casing_convention_is_applied_to_Post_endpoint() operationElement.Should().Be("PostSupermarket"); }); - documentSchemaRefId = getElement.Should().ContainPath("requestBody.content['application/vnd.api+json'].schema.$ref") + documentSchemaRefId = getElement.Should().ContainPath("requestBody.content['application/vnd.api+json'].schema.allOf[0].$ref") .ShouldBeSchemaReferenceId("SupermarketPostRequestDocument").SchemaReferenceId; }); @@ -387,7 +385,7 @@ public async Task Casing_convention_is_applied_to_Post_endpoint() schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.$ref").ShouldBeSchemaReferenceId("SupermarketDataInPostRequest") + resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.allOf[0].$ref").ShouldBeSchemaReferenceId("SupermarketDataInPostRequest") .SchemaReferenceId; }); @@ -395,22 +393,22 @@ public async Task Casing_convention_is_applied_to_Post_endpoint() schemasElement.Should().ContainPath($"{resourceDataSchemaRefId}.properties").With(propertiesElement => { - propertiesElement.Should().ContainPath("attributes.$ref").ShouldBeSchemaReferenceId("SupermarketAttributesInPostRequest"); + propertiesElement.Should().ContainPath("attributes.allOf[0].$ref").ShouldBeSchemaReferenceId("SupermarketAttributesInPostRequest"); - resourceRelationshipInPostRequestSchemaRefId = propertiesElement.Should().ContainPath("relationships.$ref") + resourceRelationshipInPostRequestSchemaRefId = propertiesElement.Should().ContainPath("relationships.allOf[0].$ref") .ShouldBeSchemaReferenceId("SupermarketRelationshipsInPostRequest").SchemaReferenceId; }); schemasElement.Should().ContainPath($"{resourceRelationshipInPostRequestSchemaRefId}.properties").With(propertiesElement => { propertiesElement.Should().ContainProperty("StoreManager"); - propertiesElement.Should().ContainPath("StoreManager.$ref").ShouldBeSchemaReferenceId("ToOneStaffMemberInRequest"); + propertiesElement.Should().ContainPath("StoreManager.allOf[0].$ref").ShouldBeSchemaReferenceId("ToOneStaffMemberInRequest"); propertiesElement.Should().ContainProperty("BackupStoreManager"); - propertiesElement.Should().ContainPath("BackupStoreManager.$ref").ShouldBeSchemaReferenceId("NullableToOneStaffMemberInRequest"); + propertiesElement.Should().ContainPath("BackupStoreManager.allOf[0].$ref").ShouldBeSchemaReferenceId("NullableToOneStaffMemberInRequest"); propertiesElement.Should().ContainProperty("Cashiers"); - propertiesElement.Should().ContainPath("Cashiers.$ref").ShouldBeSchemaReferenceId("ToManyStaffMemberInRequest"); + propertiesElement.Should().ContainPath("Cashiers.allOf[0].$ref").ShouldBeSchemaReferenceId("ToManyStaffMemberInRequest"); }); }); } @@ -447,7 +445,7 @@ public async Task Casing_convention_is_applied_to_Patch_endpoint() operationElement.Should().Be("PatchSupermarket"); }); - documentSchemaRefId = getElement.Should().ContainPath("requestBody.content['application/vnd.api+json'].schema.$ref") + documentSchemaRefId = getElement.Should().ContainPath("requestBody.content['application/vnd.api+json'].schema.allOf[0].$ref") .ShouldBeSchemaReferenceId("SupermarketPatchRequestDocument").SchemaReferenceId; }); @@ -457,14 +455,14 @@ public async Task Casing_convention_is_applied_to_Patch_endpoint() schemasElement.Should().ContainPath($"{documentSchemaRefId}.properties").With(propertiesElement => { - resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.$ref").ShouldBeSchemaReferenceId("SupermarketDataInPatchRequest") - .SchemaReferenceId; + resourceDataSchemaRefId = propertiesElement.Should().ContainPath("data.allOf[0].$ref") + .ShouldBeSchemaReferenceId("SupermarketDataInPatchRequest").SchemaReferenceId; }); schemasElement.Should().ContainPath($"{resourceDataSchemaRefId}.properties").With(propertiesElement => { - propertiesElement.Should().ContainPath("attributes.$ref").ShouldBeSchemaReferenceId("SupermarketAttributesInPatchRequest"); - propertiesElement.Should().ContainPath("relationships.$ref").ShouldBeSchemaReferenceId("SupermarketRelationshipsInPatchRequest"); + propertiesElement.Should().ContainPath("attributes.allOf[0].$ref").ShouldBeSchemaReferenceId("SupermarketAttributesInPatchRequest"); + propertiesElement.Should().ContainPath("relationships.allOf[0].$ref").ShouldBeSchemaReferenceId("SupermarketRelationshipsInPatchRequest"); }); }); } diff --git a/test/OpenApiTests/OpenApiTests.csproj b/test/OpenApiTests/OpenApiTests.csproj index 24a6eba897..2ce6e0c12d 100644 --- a/test/OpenApiTests/OpenApiTests.csproj +++ b/test/OpenApiTests/OpenApiTests.csproj @@ -10,7 +10,8 @@ - + diff --git a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs index 0e0779daf3..5927cd79a8 100644 --- a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs +++ b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs @@ -66,9 +66,12 @@ public async Task Schema_property_for_relationship_is_nullable(string jsonProper // Assert document.Should().ContainPath("components.schemas.resourceRelationshipsInPostRequest.properties").With(schemaProperties => { - schemaProperties.Should().ContainPath($"{jsonPropertyName}.$ref").WithSchemaReferenceId(schemaReferenceId => + schemaProperties.Should().ContainPath($"{jsonPropertyName}.allOf[0].$ref").WithSchemaReferenceId(schemaReferenceId => { - document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data.oneOf[1].$ref").ShouldBeSchemaReferenceId("nullValue"); + document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data").With(relationshipDataSchema => + { + relationshipDataSchema.Should().ContainPath("nullable").With(nullableProperty => nullableProperty.Should().Be(true)); + }); }); }); } @@ -84,9 +87,12 @@ public async Task Schema_property_for_relationship_is_not_nullable(string jsonPr // Assert document.Should().ContainPath("components.schemas.resourceRelationshipsInPostRequest.properties").With(schemaProperties => { - schemaProperties.Should().ContainPath($"{jsonPropertyName}.$ref").WithSchemaReferenceId(schemaReferenceId => + schemaProperties.Should().ContainPath($"{jsonPropertyName}.allOf[0].$ref").WithSchemaReferenceId(schemaReferenceId => { - document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data").Should().NotContainPath("oneOf[1].$ref"); + document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data").With(relationshipDataSchema => + { + relationshipDataSchema.Should().NotContainPath("nullable"); + }); }); }); } diff --git a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs index e5171495f4..db0c7363e7 100644 --- a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs +++ b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs @@ -65,9 +65,12 @@ public async Task Schema_property_for_relationship_is_nullable(string jsonProper // Assert document.Should().ContainPath("components.schemas.resourceRelationshipsInPostRequest.properties").With(schemaProperties => { - schemaProperties.Should().ContainPath($"{jsonPropertyName}.$ref").WithSchemaReferenceId(schemaReferenceId => + schemaProperties.Should().ContainPath($"{jsonPropertyName}.allOf[0].$ref").WithSchemaReferenceId(schemaReferenceId => { - document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data.oneOf[1].$ref").ShouldBeSchemaReferenceId("nullValue"); + document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data").With(relationshipDataSchema => + { + relationshipDataSchema.Should().ContainPath("nullable").With(nullableProperty => nullableProperty.Should().Be(true)); + }); }); }); } @@ -84,9 +87,12 @@ public async Task Schema_property_for_relationship_is_not_nullable(string jsonPr // Assert document.Should().ContainPath("components.schemas.resourceRelationshipsInPostRequest.properties").With(schemaProperties => { - schemaProperties.Should().ContainPath($"{jsonPropertyName}.$ref").WithSchemaReferenceId(schemaReferenceId => + schemaProperties.Should().ContainPath($"{jsonPropertyName}.allOf[0].$ref").WithSchemaReferenceId(schemaReferenceId => { - document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data").Should().NotContainPath("oneOf[1].$ref"); + document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data").With(relationshipDataSchema => + { + relationshipDataSchema.Should().NotContainPath("nullable"); + }); }); }); } diff --git a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs index f497022c6d..370d6b57a8 100644 --- a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs +++ b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs @@ -68,9 +68,12 @@ public async Task Schema_property_for_relationship_is_nullable(string jsonProper // Assert document.Should().ContainPath("components.schemas.resourceRelationshipsInPostRequest.properties").With(schemaProperties => { - schemaProperties.Should().ContainPath($"{jsonPropertyName}.$ref").WithSchemaReferenceId(schemaReferenceId => + schemaProperties.Should().ContainPath($"{jsonPropertyName}.allOf[0].$ref").WithSchemaReferenceId(schemaReferenceId => { - document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data.oneOf[1].$ref").ShouldBeSchemaReferenceId("nullValue"); + document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data").With(relationshipDataSchema => + { + relationshipDataSchema.Should().ContainPath("nullable").With(nullableProperty => nullableProperty.Should().Be(true)); + }); }); }); } @@ -88,9 +91,12 @@ public async Task Schema_property_for_relationship_is_not_nullable(string jsonPr // Assert document.Should().ContainPath("components.schemas.resourceRelationshipsInPostRequest.properties").With(schemaProperties => { - schemaProperties.Should().ContainPath($"{jsonPropertyName}.$ref").WithSchemaReferenceId(schemaReferenceId => + schemaProperties.Should().ContainPath($"{jsonPropertyName}.allOf[0].$ref").WithSchemaReferenceId(schemaReferenceId => { - document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data").Should().NotContainPath("oneOf[1].$ref"); + document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data").With(relationshipDataSchema => + { + relationshipDataSchema.Should().NotContainPath("nullable"); + }); }); }); } diff --git a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs index 7062bddaab..f2b997a74d 100644 --- a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs +++ b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs @@ -67,9 +67,12 @@ public async Task Schema_property_for_relationship_is_nullable(string jsonProper // Assert document.Should().ContainPath("components.schemas.resourceRelationshipsInPostRequest.properties").With(schemaProperties => { - schemaProperties.Should().ContainPath($"{jsonPropertyName}.$ref").WithSchemaReferenceId(schemaReferenceId => + schemaProperties.Should().ContainPath($"{jsonPropertyName}.allOf[0].$ref").WithSchemaReferenceId(schemaReferenceId => { - document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data.oneOf[1].$ref").ShouldBeSchemaReferenceId("nullValue"); + document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data").With(relationshipDataSchema => + { + relationshipDataSchema.Should().ContainPath("nullable").With(nullableProperty => nullableProperty.Should().Be(true)); + }); }); }); } @@ -88,9 +91,12 @@ public async Task Schema_property_for_relationship_is_not_nullable(string jsonPr // Assert document.Should().ContainPath("components.schemas.resourceRelationshipsInPostRequest.properties").With(schemaProperties => { - schemaProperties.Should().ContainPath($"{jsonPropertyName}.$ref").WithSchemaReferenceId(schemaReferenceId => + schemaProperties.Should().ContainPath($"{jsonPropertyName}.allOf[0].$ref").WithSchemaReferenceId(schemaReferenceId => { - document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data").Should().NotContainPath("oneOf[1].$ref"); + document.Should().ContainPath($"components.schemas.{schemaReferenceId}.properties.data").With(relationshipDataSchema => + { + relationshipDataSchema.Should().NotContainPath("nullable"); + }); }); }); } From 60b63db132c5cd9fc8720c21b5234bc149889a0c Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Fri, 27 Oct 2023 03:08:06 +0200 Subject: [PATCH 2/2] Fix generated documentation on relationships and enum properties --- .../ResourceFieldObjectSchemaBuilder.cs | 9 +-- .../DocComments/DocCommentsTests.cs | 59 +++++++++++++++++-- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs index 881638c370..4011c357ac 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs @@ -154,7 +154,7 @@ public void SetMembersOfRelationshipsObject(OpenApiSchema fullSchemaForRelations { ArgumentGuard.NotNull(fullSchemaForRelationshipsObject); - foreach ((string fieldName, OpenApiSchema resourceFieldSchema) in _schemasForResourceFields) + foreach (string fieldName in _schemasForResourceFields.Keys) { RelationshipAttribute? matchingRelationship = _resourceTypeInfo.ResourceType.FindRelationshipByPublicName(fieldName); @@ -162,10 +162,6 @@ public void SetMembersOfRelationshipsObject(OpenApiSchema fullSchemaForRelations { EnsureResourceIdentifierObjectSchemaExists(matchingRelationship); AddRelationshipSchemaToResourceObject(matchingRelationship, fullSchemaForRelationshipsObject); - - // This currently has no effect because $ref cannot be combined with other elements in OAS 3.0. - // This can be worked around by using the allOf operator. See https://github.com/OAI/OpenAPI-Specification/issues/1514. - resourceFieldSchema.Description = _resourceObjectDocumentationReader.GetDocumentationForRelationship(matchingRelationship); } } } @@ -209,7 +205,8 @@ private void AddRelationshipSchemaToResourceObject(RelationshipAttribute relatio AllOf = new List { referenceSchemaForRelationship - } + }, + Description = _resourceObjectDocumentationReader.GetDocumentationForRelationship(relationship) }; fullSchemaForRelationshipsObject.Properties.Add(relationship.PublicName, extendedReferenceSchemaForRelationship); diff --git a/test/OpenApiTests/DocComments/DocCommentsTests.cs b/test/OpenApiTests/DocComments/DocCommentsTests.cs index cf14cf66fa..6d7962e47a 100644 --- a/test/OpenApiTests/DocComments/DocCommentsTests.cs +++ b/test/OpenApiTests/DocComments/DocCommentsTests.cs @@ -449,7 +449,7 @@ public async Task Resource_types_are_documented() } [Fact] - public async Task Resource_attributes_are_documented() + public async Task Attributes_are_documented() { // Act JsonElement document = await _testContext.GetSwaggerDocumentAsync(); @@ -465,9 +465,60 @@ public async Task Resource_attributes_are_documented() schemasElement.Should().HaveProperty("skyscraperAttributesInPostRequest.properties.heightInMeters.description", "The height of this building, in meters."); schemasElement.Should().HaveProperty("skyscraperAttributesInResponse.properties.heightInMeters.description", "The height of this building, in meters."); - schemasElement.Should().HaveProperty("spaceAttributesInPatchRequest.properties.floorNumber.description", "The floor number on which this space resides."); - schemasElement.Should().HaveProperty("spaceAttributesInPostRequest.properties.floorNumber.description", "The floor number on which this space resides."); - schemasElement.Should().HaveProperty("spaceAttributesInResponse.properties.floorNumber.description", "The floor number on which this space resides."); + schemasElement.Should().ContainPath("spaceAttributesInPatchRequest.properties").With(propertiesElement => + { + propertiesElement.Should().HaveProperty("floorNumber.description", "The floor number on which this space resides."); + propertiesElement.Should().HaveProperty("kind.description", "The kind of this space."); + }); + + schemasElement.Should().ContainPath("spaceAttributesInPostRequest.properties").With(propertiesElement => + { + propertiesElement.Should().HaveProperty("floorNumber.description", "The floor number on which this space resides."); + propertiesElement.Should().HaveProperty("kind.description", "The kind of this space."); + }); + + schemasElement.Should().ContainPath("spaceAttributesInResponse.properties").With(propertiesElement => + { + propertiesElement.Should().HaveProperty("floorNumber.description", "The floor number on which this space resides."); + propertiesElement.Should().HaveProperty("kind.description", "The kind of this space."); + }); + }); + } + + [Fact] + public async Task Relationships_are_documented() + { + // Act + JsonElement document = await _testContext.GetSwaggerDocumentAsync(); + + // Assert + document.Should().ContainPath("components.schemas").With(schemasElement => + { + schemasElement.Should().HaveProperty("elevatorRelationshipsInPatchRequest.properties.existsIn.description", "The skyscraper this elevator exists in."); + schemasElement.Should().HaveProperty("elevatorRelationshipsInPostRequest.properties.existsIn.description", "The skyscraper this elevator exists in."); + schemasElement.Should().HaveProperty("elevatorRelationshipsInResponse.properties.existsIn.description", "The skyscraper this elevator exists in."); + + schemasElement.Should().ContainPath("skyscraperRelationshipsInPatchRequest.properties").With(propertiesElement => + { + propertiesElement.Should().HaveProperty("elevator.description", "An optional elevator within this building, providing access to spaces."); + propertiesElement.Should().HaveProperty("spaces.description", "The spaces within this building."); + }); + + schemasElement.Should().ContainPath("skyscraperRelationshipsInPostRequest.properties").With(propertiesElement => + { + propertiesElement.Should().HaveProperty("elevator.description", "An optional elevator within this building, providing access to spaces."); + propertiesElement.Should().HaveProperty("spaces.description", "The spaces within this building."); + }); + + schemasElement.Should().ContainPath("skyscraperRelationshipsInResponse.properties").With(propertiesElement => + { + propertiesElement.Should().HaveProperty("elevator.description", "An optional elevator within this building, providing access to spaces."); + propertiesElement.Should().HaveProperty("spaces.description", "The spaces within this building."); + }); + + schemasElement.Should().HaveProperty("spaceRelationshipsInPatchRequest.properties.existsIn.description", "The skyscraper this space exists in."); + schemasElement.Should().HaveProperty("spaceRelationshipsInPostRequest.properties.existsIn.description", "The skyscraper this space exists in."); + schemasElement.Should().HaveProperty("spaceRelationshipsInResponse.properties.existsIn.description", "The skyscraper this space exists in."); }); }