From 7addf8973f3a5e5a01240dcb367f4a5b41b92087 Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Mon, 22 Jan 2024 16:21:23 +0300 Subject: [PATCH 1/7] Remove AnyOf for collection of structured type properties schema --- .../OpenApiEdmTypeSchemaGenerator.cs | 53 +++++-------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs index 7f772618..4dc10f68 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------ +// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------ @@ -461,45 +461,18 @@ private static OpenApiSchema CreateStructuredTypeSchema(this ODataContext contex Debug.Assert(context != null); Debug.Assert(typeReference != null); - OpenApiSchema schema = new OpenApiSchema(); - - // AnyOf will only be valid openApi for version 3 - // otherwise the reference should be set directly - // as per OASIS documentation for openApi version 2 - if (typeReference.IsNullable && - (context.Settings.OpenApiSpecVersion >= OpenApiSpecVersion.OpenApi3_0)) - { - schema.Reference = null; - schema.AnyOf = new List - { - new OpenApiSchema - { - UnresolvedReference = true, - Reference = new OpenApiReference - { - Type = ReferenceType.Schema, - Id = typeReference.Definition.FullTypeName() - } - }, - new OpenApiSchema - { - Type = "object", - Nullable = true - } - }; - } - else - { - schema.Type = null; - schema.AnyOf = null; - schema.Reference = new OpenApiReference - { - Type = ReferenceType.Schema, - Id = typeReference.Definition.FullTypeName() - }; - schema.UnresolvedReference = true; - schema.Nullable = typeReference.IsNullable; - } + OpenApiSchema schema = new OpenApiSchema + { + Type = null, + AnyOf = null, + Reference = new OpenApiReference + { + Type = ReferenceType.Schema, + Id = typeReference.Definition.FullTypeName() + }, + UnresolvedReference = true, + Nullable = typeReference.IsNullable + }; return schema; } From 8675cea02d5e3a768f84b7e5017bb7daa54b5a3c Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Tue, 23 Jan 2024 18:54:36 +0300 Subject: [PATCH 2/7] Update tests Removes specific tests for OpenApi spec versions 2.0 and 3.0 since they will have same schema structure --- .../OpenApiResponseGeneratorTests.cs | 59 ++++--------------- 1 file changed, 11 insertions(+), 48 deletions(-) diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiResponseGeneratorTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiResponseGeneratorTests.cs index 0ebb61c4..2fc85c55 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiResponseGeneratorTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiResponseGeneratorTests.cs @@ -161,18 +161,16 @@ public void CreateResponseForOperationThrowArgumentNullOperation() } [Theory] - [InlineData(true, OpenApiSpecVersion.OpenApi3_0)] - [InlineData(false, OpenApiSpecVersion.OpenApi3_0)] - [InlineData(true, OpenApiSpecVersion.OpenApi2_0)] - [InlineData(false, OpenApiSpecVersion.OpenApi2_0)] - public void CreateResponseForEdmFunctionReturnCorrectResponses(bool isFunctionImport, OpenApiSpecVersion specVersion) + + [InlineData(true)] + [InlineData(false)] + public void CreateResponseForEdmFunctionReturnCorrectResponses(bool isFunctionImport) { // Arrange string operationName = "GetPersonWithMostFriends"; IEdmModel model = EdmModelHelper.TripServiceModel; ODataContext context = new ODataContext(model); - context.Settings.OpenApiSpecVersion = specVersion; // Act OpenApiResponses responses; @@ -201,30 +199,11 @@ public void CreateResponseForEdmFunctionReturnCorrectResponses(bool isFunctionIm Assert.NotNull(response.Content); OpenApiMediaType mediaType = response.Content["application/json"]; - // openApi version 2 should not use AnyOf - if (specVersion == OpenApiSpecVersion.OpenApi2_0) - { - Assert.NotNull(mediaType.Schema); - Assert.Null(mediaType.Schema.AnyOf); - Assert.NotNull(mediaType.Schema.Reference); - Assert.Equal("Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person", mediaType.Schema.Reference.Id); - Assert.True(mediaType.Schema.Nullable); - } - else - { - Assert.NotNull(mediaType.Schema); - Assert.Null(mediaType.Schema.Reference); - Assert.NotNull(mediaType.Schema.AnyOf); - Assert.Equal(2, mediaType.Schema.AnyOf.Count); - var anyOfRef = mediaType.Schema.AnyOf.FirstOrDefault(); - Assert.NotNull(anyOfRef); - Assert.Equal("Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person", anyOfRef.Reference.Id); - var anyOfNull = mediaType.Schema.AnyOf.Skip(1).FirstOrDefault(); - Assert.NotNull(anyOfNull.Type); - Assert.Equal("object", anyOfNull.Type); - Assert.True(anyOfNull.Nullable); - - } + Assert.NotNull(mediaType.Schema); + Assert.Null(mediaType.Schema.AnyOf); + Assert.NotNull(mediaType.Schema.Reference); + Assert.Equal("Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person", mediaType.Schema.Reference.Id); + Assert.True(mediaType.Schema.Nullable); } [Fact] @@ -378,15 +357,7 @@ public void CreateResponseForDeltaEdmFunctionReturnCorrectResponses(bool enableO ""value"": { ""type"": ""array"", ""items"": { - ""anyOf"": [ - { - ""$ref"": ""#/components/schemas/microsoft.graph.application"" - }, - { - ""type"": ""object"", - ""nullable"": true - } - ] + ""$ref"": ""#/components/schemas/microsoft.graph.application"" } } } @@ -415,15 +386,7 @@ public void CreateResponseForDeltaEdmFunctionReturnCorrectResponses(bool enableO ""value"": { ""type"": ""array"", ""items"": { - ""anyOf"": [ - { - ""$ref"": ""#/components/schemas/microsoft.graph.application"" - }, - { - ""type"": ""object"", - ""nullable"": true - } - ] + ""$ref"": ""#/components/schemas/microsoft.graph.application"" } }, ""@odata.nextLink"": { From c8ba4a1895fc95509d6bceb3a7e56dd680e897ce Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Wed, 24 Jan 2024 13:12:30 +0300 Subject: [PATCH 3/7] Check whether type is collection before creating schema --- .../OpenApiEdmTypeSchemaGenerator.cs | 65 ++++++++++++++----- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs index 4dc10f68..ed89943c 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs @@ -33,14 +33,21 @@ public static OpenApiSchema CreateEdmTypeSchema(this ODataContext context, IEdmT Utils.CheckArgumentNull(edmTypeReference, nameof(edmTypeReference)); switch (edmTypeReference.TypeKind()) - { - case EdmTypeKind.Collection: - // Collection-valued structural and navigation are represented as Schema Objects of type array. - // The value of the items keyword is a Schema Object specifying the type of the items. + { + // Collection-valued structural and navigation are represented as Schema Objects of type array. + // The value of the items keyword is a Schema Object specifying the type of the items. + case EdmTypeKind.Collection: + + IEdmTypeReference typeRef = edmTypeReference.AsCollection().ElementType(); + OpenApiSchema schema; + schema = typeRef.TypeKind() == EdmTypeKind.Complex || typeRef.TypeKind() == EdmTypeKind.Entity + ? context.CreateStructuredTypeSchema(typeRef.AsStructured(), true) + : context.CreateEdmTypeSchema(typeRef); + return new OpenApiSchema { Type = "array", - Items = context.CreateEdmTypeSchema(edmTypeReference.AsCollection().ElementType()) + Items = schema }; // Complex, enum, entity, entity reference are represented as JSON References to the Schema Object of the complex, @@ -456,23 +463,49 @@ private static OpenApiSchema CreateEnumTypeSchema(this ODataContext context, IEd return schema; } - private static OpenApiSchema CreateStructuredTypeSchema(this ODataContext context, IEdmStructuredTypeReference typeReference) + private static OpenApiSchema CreateStructuredTypeSchema(this ODataContext context, IEdmStructuredTypeReference typeReference, bool isTypeCollection = false) { Debug.Assert(context != null); - Debug.Assert(typeReference != null); - - OpenApiSchema schema = new OpenApiSchema + Debug.Assert(typeReference != null); + + OpenApiSchema schema = new OpenApiSchema(); + + // AnyOf will only be valid openApi for version 3 + // otherwise the reference should be set directly + // as per OASIS documentation for openApi version 2 + // Collections of structured types cannot be nullable + if (typeReference.IsNullable && !isTypeCollection && + (context.Settings.OpenApiSpecVersion >= OpenApiSpecVersion.OpenApi3_0)) { - Type = null, - AnyOf = null, - Reference = new OpenApiReference + schema.Reference = null; + schema.AnyOf = new List + { + new() { + UnresolvedReference = true, + Reference = new OpenApiReference + { + Type = ReferenceType.Schema, + Id = typeReference.Definition.FullTypeName() + } + }, + new() { + Type = "object", + Nullable = true + } + }; + } + else + { + schema.Type = null; + schema.AnyOf = null; + schema.Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = typeReference.Definition.FullTypeName() - }, - UnresolvedReference = true, - Nullable = typeReference.IsNullable - }; + }; + schema.UnresolvedReference = true; + schema.Nullable = typeReference.IsNullable; + } return schema; } From 0355d4cd26a929a3b0cf3c55e9cb8fc23ca5f2d5 Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Wed, 24 Jan 2024 13:17:00 +0300 Subject: [PATCH 4/7] Revert test --- .../OpenApiResponseGeneratorTests.cs | 111 +++++++++++------- 1 file changed, 66 insertions(+), 45 deletions(-) diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiResponseGeneratorTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiResponseGeneratorTests.cs index 2fc85c55..b6e9dc7e 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiResponseGeneratorTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiResponseGeneratorTests.cs @@ -159,51 +159,72 @@ public void CreateResponseForOperationThrowArgumentNullOperation() // Act & Assert Assert.Throws("operation", () => context.CreateResponses(operation: null)); } - - [Theory] - - [InlineData(true)] - [InlineData(false)] - public void CreateResponseForEdmFunctionReturnCorrectResponses(bool isFunctionImport) - { - // Arrange - string operationName = "GetPersonWithMostFriends"; - IEdmModel model = EdmModelHelper.TripServiceModel; - ODataContext context = new ODataContext(model); - - - // Act - OpenApiResponses responses; - if (isFunctionImport) - { - IEdmOperationImport operationImport = model.EntityContainer.OperationImports().First(o => o.Name == operationName); - Assert.NotNull(operationImport); // guard - ODataPath path = new ODataPath(new ODataOperationImportSegment(operationImport)); - responses = context.CreateResponses(operationImport); - } - else - { - IEdmOperation operation = model.SchemaElements.OfType().First(o => o.Name == operationName); - Assert.NotNull(operation); // guard - ODataPath path = new ODataPath(new ODataOperationSegment(operation)); - responses = context.CreateResponses(operation); - } - - // Assert - Assert.NotNull(responses); - Assert.NotEmpty(responses); - Assert.Equal(2, responses.Count); - Assert.Equal(new string[] { "200", "default" }, responses.Select(r => r.Key)); - - OpenApiResponse response = responses["200"]; - Assert.NotNull(response.Content); - OpenApiMediaType mediaType = response.Content["application/json"]; - - Assert.NotNull(mediaType.Schema); - Assert.Null(mediaType.Schema.AnyOf); - Assert.NotNull(mediaType.Schema.Reference); - Assert.Equal("Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person", mediaType.Schema.Reference.Id); - Assert.True(mediaType.Schema.Nullable); + + [Theory] + [InlineData(true, OpenApiSpecVersion.OpenApi3_0)] + [InlineData(false, OpenApiSpecVersion.OpenApi3_0)] + [InlineData(true, OpenApiSpecVersion.OpenApi2_0)] + [InlineData(false, OpenApiSpecVersion.OpenApi2_0)] + public void CreateResponseForEdmFunctionReturnCorrectResponses(bool isFunctionImport, OpenApiSpecVersion specVersion) + { + // Arrange + string operationName = "GetPersonWithMostFriends"; + IEdmModel model = EdmModelHelper.TripServiceModel; + ODataContext context = new ODataContext(model); + + context.Settings.OpenApiSpecVersion = specVersion; + + // Act + OpenApiResponses responses; + if (isFunctionImport) + { + IEdmOperationImport operationImport = model.EntityContainer.OperationImports().First(o => o.Name == operationName); + Assert.NotNull(operationImport); // guard + ODataPath path = new ODataPath(new ODataOperationImportSegment(operationImport)); + responses = context.CreateResponses(operationImport); + } + else + { + IEdmOperation operation = model.SchemaElements.OfType().First(o => o.Name == operationName); + Assert.NotNull(operation); // guard + ODataPath path = new ODataPath(new ODataOperationSegment(operation)); + responses = context.CreateResponses(operation); + } + + // Assert + Assert.NotNull(responses); + Assert.NotEmpty(responses); + Assert.Equal(2, responses.Count); + Assert.Equal(new string[] { "200", "default" }, responses.Select(r => r.Key)); + + OpenApiResponse response = responses["200"]; + Assert.NotNull(response.Content); + OpenApiMediaType mediaType = response.Content["application/json"]; + + // openApi version 2 should not use AnyOf + if (specVersion == OpenApiSpecVersion.OpenApi2_0) + { + Assert.NotNull(mediaType.Schema); + Assert.Null(mediaType.Schema.AnyOf); + Assert.NotNull(mediaType.Schema.Reference); + Assert.Equal("Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person", mediaType.Schema.Reference.Id); + Assert.True(mediaType.Schema.Nullable); + } + else + { + Assert.NotNull(mediaType.Schema); + Assert.Null(mediaType.Schema.Reference); + Assert.NotNull(mediaType.Schema.AnyOf); + Assert.Equal(2, mediaType.Schema.AnyOf.Count); + var anyOfRef = mediaType.Schema.AnyOf.FirstOrDefault(); + Assert.NotNull(anyOfRef); + Assert.Equal("Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person", anyOfRef.Reference.Id); + var anyOfNull = mediaType.Schema.AnyOf.Skip(1).FirstOrDefault(); + Assert.NotNull(anyOfNull.Type); + Assert.Equal("object", anyOfNull.Type); + Assert.True(anyOfNull.Nullable); + + } } [Fact] From 45c015adc5a127decbee12fcd902c030fa7ee852 Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Wed, 24 Jan 2024 16:07:41 +0300 Subject: [PATCH 5/7] Minor format changes --- .../Generator/OpenApiEdmTypeSchemaGenerator.cs | 6 ++++-- .../Generator/OpenApiResponseGeneratorTests.cs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs index ed89943c..06673317 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiEdmTypeSchemaGenerator.cs @@ -480,7 +480,8 @@ private static OpenApiSchema CreateStructuredTypeSchema(this ODataContext contex schema.Reference = null; schema.AnyOf = new List { - new() { + new OpenApiSchema + { UnresolvedReference = true, Reference = new OpenApiReference { @@ -488,7 +489,8 @@ private static OpenApiSchema CreateStructuredTypeSchema(this ODataContext contex Id = typeReference.Definition.FullTypeName() } }, - new() { + new OpenApiSchema + { Type = "object", Nullable = true } diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiResponseGeneratorTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiResponseGeneratorTests.cs index b6e9dc7e..857b2740 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiResponseGeneratorTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiResponseGeneratorTests.cs @@ -158,8 +158,8 @@ public void CreateResponseForOperationThrowArgumentNullOperation() // Act & Assert Assert.Throws("operation", () => context.CreateResponses(operation: null)); - } - + } + [Theory] [InlineData(true, OpenApiSpecVersion.OpenApi3_0)] [InlineData(false, OpenApiSpecVersion.OpenApi3_0)] From 1a74f099a8adf17302b1c354789cf3510afd9299 Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Wed, 24 Jan 2024 16:22:06 +0300 Subject: [PATCH 6/7] Update integration tests --- .../OpenApiEdmTypeSchemaGeneratorTest.cs | 10 +- .../Resources/Multiple.Schema.OpenApi.json | 40 +------ .../Resources/Multiple.Schema.OpenApi.yaml | 20 +--- .../Resources/TripService.OpenApi.json | 100 ++---------------- .../Resources/TripService.OpenApi.yaml | 50 ++------- 5 files changed, 29 insertions(+), 191 deletions(-) diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiEdmTypeSchemaGeneratorTest.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiEdmTypeSchemaGeneratorTest.cs index c8ea45f1..efa5eb6f 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiEdmTypeSchemaGeneratorTest.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiEdmTypeSchemaGeneratorTest.cs @@ -78,15 +78,7 @@ public void CreateEdmTypeSchemaReturnSchemaForNullableCollectionComplexType(Open Assert.Equal(@"{ ""type"": ""array"", ""items"": { - ""anyOf"": [ - { - ""$ref"": ""#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation"" - }, - { - ""type"": ""object"", - ""nullable"": true - } - ] + ""$ref"": ""#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation"" } }".ChangeLineBreaks(), json); } diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Multiple.Schema.OpenApi.json b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Multiple.Schema.OpenApi.json index f895967e..ce0f2ac5 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Multiple.Schema.OpenApi.json +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Multiple.Schema.OpenApi.json @@ -4716,15 +4716,7 @@ "Tags": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Siterra.Documents.App.DTO.DocumentTagRelDto" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Siterra.Documents.App.DTO.DocumentTagRelDto" } }, "Revisions": { @@ -5307,29 +5299,13 @@ "DocumentClasses": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Document.DocumentClass" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Document.DocumentClass" } }, "Tags": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Document.DocumentTagRel" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Document.DocumentTagRel" } }, "Library": { @@ -6311,15 +6287,7 @@ "Documents": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Document.DocumentTagRel" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Document.DocumentTagRel" } } } diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Multiple.Schema.OpenApi.yaml b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Multiple.Schema.OpenApi.yaml index 18f9bc92..440c2836 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Multiple.Schema.OpenApi.yaml +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Multiple.Schema.OpenApi.yaml @@ -3319,10 +3319,7 @@ components: Tags: type: array items: - anyOf: - - $ref: '#/components/schemas/Siterra.Documents.App.DTO.DocumentTagRelDto' - - type: object - nullable: true + $ref: '#/components/schemas/Siterra.Documents.App.DTO.DocumentTagRelDto' Revisions: type: array items: @@ -3785,17 +3782,11 @@ components: DocumentClasses: type: array items: - anyOf: - - $ref: '#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Document.DocumentClass' - - type: object - nullable: true + $ref: '#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Document.DocumentClass' Tags: type: array items: - anyOf: - - $ref: '#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Document.DocumentTagRel' - - type: object - nullable: true + $ref: '#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Document.DocumentTagRel' Library: anyOf: - $ref: '#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Library.Library' @@ -4537,10 +4528,7 @@ components: Documents: type: array items: - anyOf: - - $ref: '#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Document.DocumentTagRel' - - type: object - nullable: true + $ref: '#/components/schemas/Siterra.Documents.BusinessLogic.Entities.Document.DocumentTagRel' example: Id: integer (identifier) DomainId: integer diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.json b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.json index bcb6914a..635ce3f4 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.json +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.json @@ -7775,15 +7775,7 @@ "value": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" } } } @@ -12205,15 +12197,7 @@ "value": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" } } } @@ -13253,15 +13237,7 @@ "value": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" } } } @@ -17791,15 +17767,7 @@ "value": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" } } } @@ -26056,15 +26024,7 @@ "value": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" } } } @@ -31284,15 +31244,7 @@ "value": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" } } } @@ -32486,15 +32438,7 @@ "value": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" } } } @@ -33542,15 +33486,7 @@ "AddressInfo": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" } }, "HomeAddress": { @@ -34674,15 +34610,7 @@ "value": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip" } } } @@ -34717,15 +34645,7 @@ "value": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - { - "type": "object", - "nullable": true - } - ] + "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" } } } diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.yaml b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.yaml index ef452516..2f1e6be2 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.yaml +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.yaml @@ -5397,10 +5397,7 @@ paths: value: type: array items: - anyOf: - - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' - - type: object - nullable: true + $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' default: $ref: '#/components/responses/error' deprecated: true @@ -8494,10 +8491,7 @@ paths: value: type: array items: - anyOf: - - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' - - type: object - nullable: true + $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' default: $ref: '#/components/responses/error' deprecated: true @@ -9237,10 +9231,7 @@ paths: value: type: array items: - anyOf: - - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' - - type: object - nullable: true + $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' default: $ref: '#/components/responses/error' deprecated: true @@ -12377,10 +12368,7 @@ paths: value: type: array items: - anyOf: - - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' - - type: object - nullable: true + $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' default: $ref: '#/components/responses/error' x-ms-docs-operation-type: function @@ -18153,10 +18141,7 @@ paths: value: type: array items: - anyOf: - - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' - - type: object - nullable: true + $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' default: $ref: '#/components/responses/error' deprecated: true @@ -21801,10 +21786,7 @@ paths: value: type: array items: - anyOf: - - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' - - type: object - nullable: true + $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' default: $ref: '#/components/responses/error' deprecated: true @@ -22651,10 +22633,7 @@ paths: value: type: array items: - anyOf: - - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' - - type: object - nullable: true + $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' default: $ref: '#/components/responses/error' deprecated: true @@ -23382,10 +23361,7 @@ components: AddressInfo: type: array items: - anyOf: - - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location' - - type: object - nullable: true + $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location' HomeAddress: anyOf: - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location' @@ -24085,10 +24061,7 @@ components: value: type: array items: - anyOf: - - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip' - - type: object - nullable: true + $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip' UpdatePersonLastNameResponse: description: Success content: @@ -24110,10 +24083,7 @@ components: value: type: array items: - anyOf: - - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' - - type: object - nullable: true + $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' parameters: top: name: $top From d9b10764b28ce62ab4d9d9714d41f56dccd6a75f Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Wed, 24 Jan 2024 16:24:52 +0300 Subject: [PATCH 7/7] Update release notes --- .../Microsoft.OpenAPI.OData.Reader.csproj | 143 +++++++++--------- 1 file changed, 72 insertions(+), 71 deletions(-) diff --git a/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj b/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj index 116d8de2..fab1671d 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj +++ b/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj @@ -1,71 +1,72 @@ - - - - Microsoft.OpenApi.OData.Reader - Latest - true - icon.png - https://github.com/Microsoft/OpenAPI.NET.OData - MIT - true - Microsoft - Microsoft - Microsoft Open API OData Reader - Microsoft.OpenApi.OData - netstandard2.0 - Microsoft.OpenApi.OData - true - 1.6.0-preview.3 - This package contains the codes you need to convert OData CSDL to Open API Document of Model. - © Microsoft Corporation. All rights reserved. - Microsoft OpenApi OData EDM - https://github.com/Microsoft/OpenAPI.NET.OData - -- Reads annotations on structural properties of stream types for media entity paths #399 -- Updates the format of the request body schema of a collection of complex property #423 -- Adds a delete operation and a required @id query parameter to collection-valued navigation property paths with $ref #453 - - Microsoft.OpenApi.OData.Reader - ..\..\tool\Microsoft.OpenApi.OData.snk - ..\..\bin\Debug\ - ..\..\bin\Release\ - false - ..\..\bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml - - true - README.md - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - True - True - SRResource.resx - - - - - - ResXFileCodeGenerator - SRResource.Designer.cs - - - - + + + + Microsoft.OpenApi.OData.Reader + Latest + true + icon.png + https://github.com/Microsoft/OpenAPI.NET.OData + MIT + true + Microsoft + Microsoft + Microsoft Open API OData Reader + Microsoft.OpenApi.OData + netstandard2.0 + Microsoft.OpenApi.OData + true + 1.6.0-preview.4 + This package contains the codes you need to convert OData CSDL to Open API Document of Model. + © Microsoft Corporation. All rights reserved. + Microsoft OpenApi OData EDM + https://github.com/Microsoft/OpenAPI.NET.OData + +- Reads annotations on structural properties of stream types for media entity paths #399 +- Updates the format of the request body schema of a collection of complex property #423 +- Adds a delete operation and a required @id query parameter to collection-valued navigation property paths with $ref #453 +- Fixes inconsistency of nullability of schemas of properties that are a collection of structured types #467 + + Microsoft.OpenApi.OData.Reader + ..\..\tool\Microsoft.OpenApi.OData.snk + ..\..\bin\Debug\ + ..\..\bin\Release\ + false + ..\..\bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + + true + README.md + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + True + True + SRResource.resx + + + + + + ResXFileCodeGenerator + SRResource.Designer.cs + + + +