From f4bdd78d8354d7f4c97543917259a0615db2dec5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Aug 2024 18:12:55 +0000 Subject: [PATCH 01/10] Bump Microsoft.OData.Edm from 7.21.3 to 8.0.0 Bumps Microsoft.OData.Edm from 7.21.3 to 8.0.0. --- updated-dependencies: - dependency-name: Microsoft.OData.Edm dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenAPI.OData.Reader.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 07b56d42..cc3ee1b8 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj +++ b/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj @@ -41,7 +41,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all From d2831cbf790db250bf318cf38c267cc7d23bb82e Mon Sep 17 00:00:00 2001 From: Millicent Achieng Date: Thu, 15 Aug 2024 15:32:05 +0300 Subject: [PATCH 02/10] Update tests --- .../Common/EdmModelHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Common/EdmModelHelper.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Common/EdmModelHelper.cs index bc00e640..b142a3b3 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Common/EdmModelHelper.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Common/EdmModelHelper.cs @@ -362,7 +362,7 @@ public void MultipleInheritanceEdmModelMetadataDocumentTest() - + @@ -378,7 +378,7 @@ public void MultipleInheritanceEdmModelMetadataDocumentTest() - + From 53b103b11b68de4a73355a127147da07dfee70f9 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 15 Aug 2024 09:24:34 -0400 Subject: [PATCH 03/10] chore: clears obsolete APIs Signed-off-by: Vincent Biret --- .../Edm/EdmModelExtensions.cs | 37 ------------------ .../Edm/ODataSegment.cs | 5 --- .../OpenApiConvertSettings.cs | 39 +++---------------- .../OpenApiDeprecationExtension.cs | 26 ------------- .../OpenApiEnumFlagsExtension.cs | 18 --------- .../OpenApiPrimaryErrorMessageExtension.cs | 14 ------- .../EdmModelOpenApiExtensionsTest.cs | 4 +- 7 files changed, 6 insertions(+), 137 deletions(-) delete mode 100644 src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiDeprecationExtension.cs delete mode 100644 src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiEnumFlagsExtension.cs delete mode 100644 src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiPrimaryErrorMessageExtension.cs diff --git a/src/Microsoft.OpenApi.OData.Reader/Edm/EdmModelExtensions.cs b/src/Microsoft.OpenApi.OData.Reader/Edm/EdmModelExtensions.cs index 4400677d..c74a782e 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Edm/EdmModelExtensions.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Edm/EdmModelExtensions.cs @@ -145,43 +145,6 @@ public static IEnumerable FindAllBaseTypes(this IEdmComplexType } } - /// - /// Checks if the is assignable to . - /// In other words, if is a subtype of or not. - /// - /// Type of the base type. - /// Type of the sub type. - /// true, if the is assignable to . Otherwise returns false. - [Obsolete] - public static bool IsAssignableFrom(this IEdmEntityType baseType, IEdmEntityType subtype) - { - Utils.CheckArgumentNull(baseType, nameof(baseType)); - Utils.CheckArgumentNull(subtype, nameof(subtype)); - - if (baseType.TypeKind != subtype.TypeKind) - { - return false; - } - - if (subtype.IsEquivalentTo(baseType)) - { - return true; - } - - IEdmStructuredType structuredSubType = subtype; - while (structuredSubType != null) - { - if (structuredSubType.IsEquivalentTo(baseType)) - { - return true; - } - - structuredSubType = structuredSubType.BaseType; - } - - return false; - } - /// /// Check whether the operation is overload in the model. /// diff --git a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataSegment.cs b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataSegment.cs index ddee0ed7..7a262d10 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataSegment.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataSegment.cs @@ -127,11 +127,6 @@ public string GetPathHash(OpenApiConvertSettings settings, ODataPath path = defa /// The path item name. public abstract string GetPathItemName(OpenApiConvertSettings settings, HashSet parameters); - /// - /// Provides any deprecation information for the segment. - /// - [Obsolete("This property never returned any value or was used by the library.")] - public Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiDeprecationExtension Deprecation { get; set; } /// /// Returns the list of this segment refers to. /// diff --git a/src/Microsoft.OpenApi.OData.Reader/OpenApiConvertSettings.cs b/src/Microsoft.OpenApi.OData.Reader/OpenApiConvertSettings.cs index a6c538c8..188675bf 100644 --- a/src/Microsoft.OpenApi.OData.Reader/OpenApiConvertSettings.cs +++ b/src/Microsoft.OpenApi.OData.Reader/OpenApiConvertSettings.cs @@ -22,19 +22,6 @@ public class OpenApiConvertSettings /// public Uri ServiceRoot { get; set; } = new Uri("http://localhost"); - /// - /// Get/set the metadata version. - /// - [Obsolete("Use SemVerVersion to Get or Set the metadata version.")] - public Version Version - { - get => Version.TryParse(SemVerVersion, out var version) ? version : null; - set - { - SemVerVersion = value?.ToString() ?? "1.0.1"; - } - } - /// /// Get/set the metadata version. /// @@ -118,12 +105,6 @@ public Version Version /// public bool EnableCount { get; set; } - /// - /// Gets/sets a value indicating whether or not to reference @odata.nextLink and @odata.count in responses - /// - [Obsolete("Deprecated in favor of EnableODataAnnotationReferencesForResponses.")] - public bool RefBaseCollectionPaginationCountResponse { get { return EnableODataAnnotationReferencesForResponses; } } - /// /// Gets/sets a value indicating whether or not to reference @odata.nextLink, @odata.deltaLink and @odata.count in responses /// @@ -244,16 +225,6 @@ public string PathPrefix /// public bool RequireDerivedTypesConstraintForODataTypeCastSegments { get; set; } = true; - /// - /// Gets/Sets a value indicating whether or not to expand derived types to retrieve their declared navigation properties. - /// - [Obsolete("Use GenerateDerivedTypesProperties to Get or Set the value.")] - public bool ExpandDerivedTypesNavigationProperties - { - get => GenerateDerivedTypesProperties; - set => GenerateDerivedTypesProperties = value; - } - /// /// Gets/Sets a value indicating whether or not to retrieve complex or navigation properties declared in derived types. /// @@ -354,16 +325,16 @@ public bool ExpandDerivedTypesNavigationProperties /// /// Enables the use of aliases for operation segments to shorten the url path. /// - public bool EnableAliasForOperationSegments { get; set; } = false; - + public bool EnableAliasForOperationSegments { get; set; } = false; + /// /// Gets/Sets a value indicating whether or not to generate the schema of query options as an array of string values. /// If false, the schema will be generated as an array of enum string values. /// public bool UseStringArrayForQueryOptionsSchema { get; set; } = true; - /// - /// Gets/Sets a value indicating the depth to expand composable functions. + /// + /// Gets/Sets a value indicating the depth to expand composable functions. /// public int ComposableFunctionsExpansionDepth { get; set; } = 1; @@ -420,7 +391,7 @@ internal OpenApiConvertSettings Clone() NamespacePrefixToStripForInMethodPaths = this.NamespacePrefixToStripForInMethodPaths, EnableAliasForTypeCastSegments = this.EnableAliasForTypeCastSegments, SemVerVersion = this.SemVerVersion, - EnableAliasForOperationSegments = this.EnableAliasForOperationSegments, + EnableAliasForOperationSegments = this.EnableAliasForOperationSegments, UseStringArrayForQueryOptionsSchema = this.UseStringArrayForQueryOptionsSchema, ComposableFunctionsExpansionDepth = this.ComposableFunctionsExpansionDepth }; diff --git a/src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiDeprecationExtension.cs b/src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiDeprecationExtension.cs deleted file mode 100644 index 6cab26a5..00000000 --- a/src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiDeprecationExtension.cs +++ /dev/null @@ -1,26 +0,0 @@ -// ------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. -// ------------------------------------------------------------ - -using System; - -namespace Microsoft.OpenApi.OData.OpenApiExtensions; - -/// -[Obsolete("This class is deprecated. Use Microsoft.OpenApi.MicrosoftExtensions.OpenApiDeprecationExtension instead.")] -public class OpenApiDeprecationExtension : Microsoft.OpenApi.MicrosoftExtensions.OpenApiDeprecationExtension -{ - /// - /// Name of the extension use in OpenAPI document. - /// - public new string Name => Microsoft.OpenApi.MicrosoftExtensions.OpenApiDeprecationExtension.Name; - /// - /// The date at which the element has been/will be removed entirely from the service. - /// - public new DateTime? RemovalDate { get => base.RemovalDate.HasValue ? base.RemovalDate.Value.DateTime : default; set => base.RemovalDate = value.HasValue ? new DateTimeOffset(value.Value) : default; } - /// - /// The date at which the element has been/will be deprecated. - /// - public new DateTime? Date { get => base.Date.HasValue ? base.Date.Value.DateTime : default; set => base.Date = value.HasValue ? new DateTimeOffset(value.Value) : default; } -} \ No newline at end of file diff --git a/src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiEnumFlagsExtension.cs b/src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiEnumFlagsExtension.cs deleted file mode 100644 index 0929d483..00000000 --- a/src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiEnumFlagsExtension.cs +++ /dev/null @@ -1,18 +0,0 @@ -// ------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. -// ------------------------------------------------------------ - -using System; - -namespace Microsoft.OpenApi.OData.OpenApiExtensions; - -/// -[Obsolete("This class is deprecated. Use Microsoft.OpenApi.MicrosoftExtensions.OpenApiEnumFlagsExtension instead.")] -public class OpenApiEnumFlagsExtension : Microsoft.OpenApi.MicrosoftExtensions.OpenApiEnumFlagsExtension -{ - /// - /// Name of the extension as used in the description. - /// - public new string Name => Microsoft.OpenApi.MicrosoftExtensions.OpenApiEnumFlagsExtension.Name; -} \ No newline at end of file diff --git a/src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiPrimaryErrorMessageExtension.cs b/src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiPrimaryErrorMessageExtension.cs deleted file mode 100644 index 81624e5b..00000000 --- a/src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiPrimaryErrorMessageExtension.cs +++ /dev/null @@ -1,14 +0,0 @@ -// ------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. -// ------------------------------------------------------------ - -using System; - -namespace Microsoft.OpenApi.OData.OpenApiExtensions; - -/// -[Obsolete("This class is deprecated. Use Microsoft.OpenApi.MicrosoftExtensions.OpenApiPrimaryErrorMessageExtension instead.")] -public class OpenApiPrimaryErrorMessageExtension : Microsoft.OpenApi.MicrosoftExtensions.OpenApiPrimaryErrorMessageExtension -{ -} \ No newline at end of file diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/EdmModelOpenApiExtensionsTest.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/EdmModelOpenApiExtensionsTest.cs index aba65272..d26f909b 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/EdmModelOpenApiExtensionsTest.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/EdmModelOpenApiExtensionsTest.cs @@ -247,11 +247,10 @@ public void TripServiceMetadataToOpenApiYamlWorks(OpenApiSpecVersion specVersion // Arrange IEdmModel model = EdmModelHelper.TripServiceModel; -#pragma warning disable CS0618 // Type or member is obsolete OpenApiConvertSettings settings = new OpenApiConvertSettings { EnableKeyAsSegment = true, - Version = new Version(1, 2, 3), // test that the obsolete property still works + SemVerVersion = "1.2.3", ServiceRoot = new Uri("http://services.odata.org/TrippinRESTierService"), IEEE754Compatible = true, OpenApiSpecVersion = specVersion, @@ -260,7 +259,6 @@ public void TripServiceMetadataToOpenApiYamlWorks(OpenApiSpecVersion specVersion AppendBoundOperationsOnDerivedTypeCastSegments = true, IncludeAssemblyInfo = false }; -#pragma warning restore CS0618 // Type or member is obsolete // Act string yaml = WriteEdmModelAsOpenApi(model, OpenApiFormat.Yaml, settings); From 164a8a4f1b3bb08a5b1019030da7d49c771f697a Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 15 Aug 2024 09:29:41 -0400 Subject: [PATCH 04/10] chore: replaces extension method call by property Signed-off-by: Vincent Biret --- .../Edm/EdmOperationProviderTests.cs | 4 +- .../Generator/OpenApiLinkGeneratorTests.cs | 6 +- ...ComplexPropertyGetOperationHandlerTests.cs | 10 +- ...mplexPropertyPatchOperationHandlerTests.cs | 8 +- ...omplexPropertyPostOperationHandlerTests.cs | 8 +- ...ComplexPropertyPutOperationHandlerTests.cs | 16 ++-- .../DollarCountGetOperationHandlerTests.cs | 4 +- .../EdmActionOperationHandlerTests.cs | 4 +- .../EdmFunctionOperationHandlerTests.cs | 56 +++++------ .../EntityDeleteOperationHandlerTests.cs | 4 +- .../EntityGetOperationHandlerTests.cs | 6 +- .../EntityPatchOperationHandlerTests.cs | 4 +- .../EntityPutOperationHandlerTests.cs | 10 +- .../MediaEntityDeleteOperationHandlerTests.cs | 6 +- .../MediaEntityGetOperationHandlerTests.cs | 4 +- .../MediaEntityPutOperationHandlerTests.cs | 6 +- ...tionPropertyDeleteOperationHandlerTests.cs | 4 +- ...igationPropertyGetOperationHandlerTests.cs | 94 +++++++++---------- ...ationPropertyPatchOperationHandlerTests.cs | 8 +- ...gationPropertyPostOperationHandlerTests.cs | 68 +++++++------- ...igationPropertyPutOperationHandlerTests.cs | 4 +- .../ODataTypeCastGetOperationHandlerTests.cs | 12 +-- .../RefDeleteOperationHandlerTests.cs | 2 +- .../Operation/RefGetOperationHandlerTests.cs | 2 +- .../Operation/RefPostOperationHandlerTests.cs | 2 +- .../Operation/RefPutOperationHandlerTests.cs | 2 +- .../ComplexPropertyPathItemHandlerTests.cs | 10 +- .../PathItem/EntityPathItemHandlerTests.cs | 10 +- .../PathItem/EntitySetPathItemHandlerTests.cs | 2 +- .../MediaEntityPathItemHandlerTests.cs | 6 +- .../NavigationPropertyPathItemHandlerTests.cs | 8 +- .../ODataTypeCastPathItemHandlerTests.cs | 2 +- .../PathItem/RefPathItemHandlerTests.cs | 2 +- 33 files changed, 197 insertions(+), 197 deletions(-) diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Edm/EdmOperationProviderTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Edm/EdmOperationProviderTests.cs index 09221e1b..574b9b2b 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Edm/EdmOperationProviderTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Edm/EdmOperationProviderTests.cs @@ -31,7 +31,7 @@ public void FindOperationsReturnsCorrectCollectionOrOperations() IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("users"); // Act - var operations = provider.FindOperations(entitySet.EntityType(), false); + var operations = provider.FindOperations(entitySet.EntityType, false); // Assert Assert.Equal(30, operations.Count()); @@ -39,7 +39,7 @@ public void FindOperationsReturnsCorrectCollectionOrOperations() // Act entitySet = model.EntityContainer.FindEntitySet("directoryObjects"); - operations = provider.FindOperations(entitySet.EntityType(), false); + operations = provider.FindOperations(entitySet.EntityType, false); // Assert Assert.Equal(58, operations.Count()); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiLinkGeneratorTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiLinkGeneratorTests.cs index 57a128f8..8110f075 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiLinkGeneratorTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiLinkGeneratorTests.cs @@ -151,7 +151,7 @@ public void CreateLinksForSingletons() // Act IDictionary links = context.CreateLinks( - entityType: singleton.EntityType(), + entityType: singleton.EntityType, entityName: singleton.Name, entityKind: singleton.ContainerElementKind.ToString(), path: path); @@ -203,7 +203,7 @@ public void CreateLinksForEntities() ODataPath path = new( new ODataNavigationSourceSegment(entityset), - new ODataKeySegment(entityset.EntityType())); + new ODataKeySegment(entityset.EntityType)); var parameters = new List() { @@ -222,7 +222,7 @@ public void CreateLinksForEntities() // Act IDictionary links = context.CreateLinks( - entityType: entityset.EntityType(), + entityType: entityset.EntityType, entityName: entityset.Name, entityKind: entityset.ContainerElementKind.ToString(), path: path, diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyGetOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyGetOperationHandlerTests.cs index 7a7b86b0..1290934e 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyGetOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyGetOperationHandlerTests.cs @@ -23,14 +23,14 @@ public void CreateComplexPropertyGetOperationReturnsCorrectOperationForSingle(bo // Arrange var model = EntitySetGetOperationHandlerTests.GetEdmModel(""); var entitySet = model.EntityContainer.FindEntitySet("Customers"); - var entity = entitySet.EntityType(); + var entity = entitySet.EntityType; var property = entity.FindProperty("BillingAddress"); var settings = new OpenApiConvertSettings { EnableOperationId = enableOperationId }; var context = new ODataContext(model, settings); - var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); + var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); // Act var get = _operationHandler.CreateOperation(context, path); @@ -66,7 +66,7 @@ public void CreateComplexPropertyGetOperationReturnsCorrectOperationForCollectio // Arrange var model = EntitySetGetOperationHandlerTests.GetEdmModel(""); var entitySet = model.EntityContainer.FindEntitySet("Customers"); - var entity = entitySet.EntityType(); + var entity = entitySet.EntityType; var property = entity.FindProperty("AlternativeAddresses"); var settings = new OpenApiConvertSettings { @@ -74,7 +74,7 @@ public void CreateComplexPropertyGetOperationReturnsCorrectOperationForCollectio UseSuccessStatusCodeRange = useHTTPStatusCodeClass2XX }; var context = new ODataContext(model, settings); - var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); + var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); // Act var get = _operationHandler.CreateOperation(context, path); @@ -111,7 +111,7 @@ public void CreateComplexPropertyGetOperationWithTargetPathAnnotationsReturnsCor IEdmEntitySet people = model.EntityContainer.FindEntitySet("People"); Assert.NotNull(people); - IEdmEntityType person = people.EntityType(); + IEdmEntityType person = people.EntityType; IEdmProperty complexProperty = person.FindProperty("FavoriteFeature"); ODataPath path = new (new ODataNavigationSourceSegment(people), new ODataKeySegment(person), new ODataComplexPropertySegment(complexProperty as IEdmStructuralProperty)); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyPatchOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyPatchOperationHandlerTests.cs index 4d29528a..c1679481 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyPatchOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyPatchOperationHandlerTests.cs @@ -23,14 +23,14 @@ public void CreateComplexPropertyDeleteOperationReturnsCorrectOperationForSingle // Arrange var model = EntitySetGetOperationHandlerTests.GetEdmModel(""); var entitySet = model.EntityContainer.FindEntitySet("Customers"); - var entity = entitySet.EntityType(); + var entity = entitySet.EntityType; var property = entity.FindProperty("BillingAddress"); var settings = new OpenApiConvertSettings { EnableOperationId = enableOperationId }; var context = new ODataContext(model, settings); - var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); + var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); // Act var patch = _operationHandler.CreateOperation(context, path); @@ -66,7 +66,7 @@ public void CreateComplexPropertyPatchOperationReturnsCorrectOperationForCollect // Arrange var model = EntitySetGetOperationHandlerTests.GetEdmModel(""); var entitySet = model.EntityContainer.FindEntitySet("Customers"); - var entity = entitySet.EntityType(); + var entity = entitySet.EntityType; var property = entity.FindProperty("BillingAddress"); var settings = new OpenApiConvertSettings { @@ -74,7 +74,7 @@ public void CreateComplexPropertyPatchOperationReturnsCorrectOperationForCollect UseSuccessStatusCodeRange = useHTTPStatusCodeClass2XX }; var context = new ODataContext(model, settings); - var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); + var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); // Act var patch = _operationHandler.CreateOperation(context, path); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyPostOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyPostOperationHandlerTests.cs index 9510c614..20abd211 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyPostOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyPostOperationHandlerTests.cs @@ -20,11 +20,11 @@ public void CreateComplexPropertyPostOperationThrowsForSingle() // Arrange var model = EntitySetPostOperationHandlerTests.GetEdmModel(""); var entitySet = model.EntityContainer.FindEntitySet("Customers"); - var entity = entitySet.EntityType(); + var entity = entitySet.EntityType; var property = entity.FindProperty("BillingAddress"); var settings = new OpenApiConvertSettings(); var context = new ODataContext(model, settings); - var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); + var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); // Act Assert.Throws(() => _operationHandler.CreateOperation(context, path)); @@ -39,7 +39,7 @@ public void CreateComplexPropertyPostOperationReturnsCorrectOperationForCollecti // Arrange var model = EntitySetPostOperationHandlerTests.GetEdmModel(""); var entitySet = model.EntityContainer.FindEntitySet("Customers"); - var entity = entitySet.EntityType(); + var entity = entitySet.EntityType; var property = entity.FindProperty("AlternativeAddresses"); var settings = new OpenApiConvertSettings { @@ -47,7 +47,7 @@ public void CreateComplexPropertyPostOperationReturnsCorrectOperationForCollecti UseSuccessStatusCodeRange = useHTTPStatusCodeClass2XX }; var context = new ODataContext(model, settings); - var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); + var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); // Act var post = _operationHandler.CreateOperation(context, path); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyPutOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyPutOperationHandlerTests.cs index 007b362f..e7c317ec 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyPutOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ComplexPropertyPutOperationHandlerTests.cs @@ -24,7 +24,7 @@ public void CreateComplexPropertyPutOperationReturnsCorrectOperationForSingle(bo // Arrange var model = EntitySetGetOperationHandlerTests.GetEdmModel(""); var entitySet = model.EntityContainer.FindEntitySet("Customers"); - var entity = entitySet.EntityType(); + var entity = entitySet.EntityType; var property = entity.FindProperty("BillingAddress"); var settings = new OpenApiConvertSettings { @@ -32,7 +32,7 @@ public void CreateComplexPropertyPutOperationReturnsCorrectOperationForSingle(bo UseSuccessStatusCodeRange = useHTTPStatusCodeClass2XX }; var context = new ODataContext(model, settings); - var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); + var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); // Act var put = _operationHandler.CreateOperation(context, path); @@ -76,14 +76,14 @@ public void CreateComplexPropertyPutOperationReturnsCorrectOperationForCollectio // Arrange var model = EntitySetGetOperationHandlerTests.GetEdmModel(""); var entitySet = model.EntityContainer.FindEntitySet("Customers"); - var entity = entitySet.EntityType(); + var entity = entitySet.EntityType; var property = entity.FindProperty("AlternativeAddresses"); var settings = new OpenApiConvertSettings { EnableOperationId = enableOperationId }; var context = new ODataContext(model, settings); - var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); + var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); // Act var put = _operationHandler.CreateOperation(context, path); @@ -100,12 +100,12 @@ public void CreateComplexPropertyPutOperationReturnsCorrectOperationForCollectio Assert.Equal(2, put.Responses.Count); Assert.Equal(new[] { "204", "default" }, put.Responses.Select(r => r.Key)); var schema = put.RequestBody?.Content.FirstOrDefault().Value?.Schema; - + Assert.NotNull(schema); Assert.Equal("object", schema.Type); - Assert.Equal("value", schema.Properties.FirstOrDefault().Key); - Assert.Equal("array", schema.Properties.FirstOrDefault().Value.Type); - + Assert.Equal("value", schema.Properties.FirstOrDefault().Key); + Assert.Equal("array", schema.Properties.FirstOrDefault().Value.Type); + if (enableOperationId) { Assert.Equal("Customers.UpdateAlternativeAddresses", put.OperationId); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/DollarCountGetOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/DollarCountGetOperationHandlerTests.cs index 141cf2df..f2ca5ddf 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/DollarCountGetOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/DollarCountGetOperationHandlerTests.cs @@ -37,7 +37,7 @@ public void CreateDollarCountGetOperationForNavigationPropertyReturnsCorrectOper IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Trips"); ODataPath path = new(new ODataNavigationSourceSegment(people), - new ODataKeySegment(people.EntityType()), + new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty), new ODataDollarCountSegment()); @@ -81,7 +81,7 @@ public void CreateDollarCountGetOperationForNavigationPropertyWithTargetPathAnno IEdmEntityType user = model.SchemaElements.OfType().First(c => c.Name == "user"); IEdmNavigationProperty navProperty = user.DeclaredNavigationProperties().First(c => c.Name == "appRoleAssignments"); ODataPath path = new(new ODataNavigationSourceSegment(users), - new ODataKeySegment(users.EntityType()), + new ODataKeySegment(users.EntityType), new ODataNavigationPropertySegment(navProperty), new ODataDollarCountSegment()); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EdmActionOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EdmActionOperationHandlerTests.cs index 03d87da1..323e27f1 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EdmActionOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EdmActionOperationHandlerTests.cs @@ -29,7 +29,7 @@ public void CreateOperationForEdmActionReturnsCorrectOperation() IEdmAction action = model.SchemaElements.OfType().First(f => f.Name == "ShareTrip"); Assert.NotNull(action); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType()), new ODataOperationSegment(action)); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType), new ODataOperationSegment(action)); // Act var operation = _operationHandler.CreateOperation(context, path); @@ -69,7 +69,7 @@ public void CreateOperationForEdmActionReturnsCorrectOperationHierarchicalClass( IEdmAction action = model.SchemaElements.OfType().First(f => f.Name == actionName); Assert.NotNull(action); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()), new ODataOperationSegment(action)); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType), new ODataOperationSegment(action)); // Act var operation = _operationHandler.CreateOperation(context, path); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EdmFunctionOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EdmFunctionOperationHandlerTests.cs index de817a52..9675534b 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EdmFunctionOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EdmFunctionOperationHandlerTests.cs @@ -32,7 +32,7 @@ public void SetsDeprecationInformation() IEdmFunction function = model.SchemaElements.OfType().First(f => f.Name == "GetFriendsTrips"); Assert.NotNull(function); - ODataPath path = new(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType()), new ODataOperationSegment(function)); + ODataPath path = new(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType), new ODataOperationSegment(function)); // Act var operation = _operationHandler.CreateOperation(context, path); @@ -57,7 +57,7 @@ public void DoesntSetDeprecationInformation() IEdmFunction function = model.SchemaElements.OfType().First(f => f.Name == "GetFavoriteAirline"); Assert.NotNull(function); - ODataPath path = new(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType()), new ODataOperationSegment(function)); + ODataPath path = new(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType), new ODataOperationSegment(function)); // Act var operation = _operationHandler.CreateOperation(context, path); @@ -90,7 +90,7 @@ public void CreateOperationForEdmFunctionReturnsCorrectOperation(bool useHTTPSta IEdmFunction function = model.SchemaElements.OfType().First(f => f.Name == "GetFavoriteAirline"); Assert.NotNull(function); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType()), new ODataOperationSegment(function)); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType), new ODataOperationSegment(function)); // Act var operation = _operationHandler.CreateOperation(context, path); @@ -127,7 +127,7 @@ public void CreateOperationForEdmFunctionReturnsCorrectOperationHierarchicalClas IEdmFunction function = model.SchemaElements.OfType().First(f => f.Name == functionName); Assert.NotNull(function); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()), new ODataOperationSegment(function)); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType), new ODataOperationSegment(function)); // Act var operation = _operationHandler.CreateOperation(context, path); @@ -482,35 +482,35 @@ public void CreateOperationForFunctionWithDateTimeParametersReturnsCorrectPathIt } [Fact] - public void CreateFunctionOperationWithAlternateKeyReturnsCorrectOperationId() - { - // Arrange + public void CreateFunctionOperationWithAlternateKeyReturnsCorrectOperationId() + { + // Arrange IEdmModel model = EdmModelHelper.GraphBetaModel; - ODataContext context = new(model, new OpenApiConvertSettings() + ODataContext context = new(model, new OpenApiConvertSettings() { - EnableOperationId = true + EnableOperationId = true }); - IEdmSingleton singleton = model.EntityContainer.FindSingleton("communications"); - IEdmEntityType entityType = model.SchemaElements.OfType().First(c => c.Name == "cloudCommunications"); - IEdmNavigationProperty navProp = entityType.DeclaredNavigationProperties().First(c => c.Name == "onlineMeetings"); - IEdmOperation action = model.SchemaElements.OfType().First(f => f.Name == "sendVirtualAppointmentReminderSms"); - IDictionary keyMappings = new Dictionary { { "joinWebUrl", "joinWebUrl" } }; - - ODataPath path = new(new ODataNavigationSourceSegment(singleton), - new ODataNavigationPropertySegment(navProp), - new ODataKeySegment(entityType, keyMappings) - { - IsAlternateKey = true - }, - new ODataOperationSegment(action)); - + IEdmSingleton singleton = model.EntityContainer.FindSingleton("communications"); + IEdmEntityType entityType = model.SchemaElements.OfType().First(c => c.Name == "cloudCommunications"); + IEdmNavigationProperty navProp = entityType.DeclaredNavigationProperties().First(c => c.Name == "onlineMeetings"); + IEdmOperation action = model.SchemaElements.OfType().First(f => f.Name == "sendVirtualAppointmentReminderSms"); + IDictionary keyMappings = new Dictionary { { "joinWebUrl", "joinWebUrl" } }; + + ODataPath path = new(new ODataNavigationSourceSegment(singleton), + new ODataNavigationPropertySegment(navProp), + new ODataKeySegment(entityType, keyMappings) + { + IsAlternateKey = true + }, + new ODataOperationSegment(action)); + // Act - var operation = _operationHandler.CreateOperation(context, path); - - // Assert - Assert.NotNull(operation); - Assert.Equal("communications.onlineMeetings.joinWebUrl.sendVirtualAppointmentReminderSms", operation.OperationId); + var operation = _operationHandler.CreateOperation(context, path); + + // Assert + Assert.NotNull(operation); + Assert.Equal("communications.onlineMeetings.joinWebUrl.sendVirtualAppointmentReminderSms", operation.OperationId); } } } diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityDeleteOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityDeleteOperationHandlerTests.cs index a94b8a38..8e359086 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityDeleteOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityDeleteOperationHandlerTests.cs @@ -29,7 +29,7 @@ public void CreateEntityDeleteOperationReturnsCorrectOperation(bool enableOperat EnableOperationId = enableOperationId }; ODataContext context = new ODataContext(model, settings); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType)); // Act var delete = _operationHandler.CreateOperation(context, path); @@ -127,7 +127,7 @@ public void CreateEntityDeleteReturnsSecurityForDeleteRestrictions(bool enableAn ODataContext context = new ODataContext(model); IEdmEntitySet customers = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(customers); // guard - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(customers), new ODataKeySegment(customers.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(customers), new ODataKeySegment(customers.EntityType)); // Act var delete = _operationHandler.CreateOperation(context, path); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityGetOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityGetOperationHandlerTests.cs index f02a3186..b5d275ed 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityGetOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityGetOperationHandlerTests.cs @@ -33,7 +33,7 @@ public void CreateEntityGetOperationReturnsCorrectOperation(bool enableOperation UseSuccessStatusCodeRange = useHTTPStatusCodeClass2XX }; ODataContext context = new ODataContext(model, settings); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType)); // Act var get = _operationHandler.CreateOperation(context, path); @@ -177,7 +177,7 @@ public void CreateEntityGetOperationReturnsSecurityForReadRestrictions(bool enab ODataContext context = new ODataContext(model); IEdmEntitySet customers = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(customers); // guard - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(customers), new ODataKeySegment(customers.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(customers), new ODataKeySegment(customers.EntityType)); // Act var get = _operationHandler.CreateOperation(context, path); @@ -222,7 +222,7 @@ private void VerifyParameter(string annotation, bool hasRestriction, bool suppor ODataContext context = new ODataContext(model); IEdmEntitySet customers = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(customers); // guard - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(customers), new ODataKeySegment(customers.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(customers), new ODataKeySegment(customers.EntityType)); // Act var get = _operationHandler.CreateOperation(context, path); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityPatchOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityPatchOperationHandlerTests.cs index fad725a5..5534a871 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityPatchOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityPatchOperationHandlerTests.cs @@ -32,7 +32,7 @@ public void CreateEntityPatchOperationReturnsCorrectOperation(bool enableOperati UseSuccessStatusCodeRange = useHTTPStatusCodeClass2XX }; ODataContext context = new ODataContext(model, settings); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType)); // Act var patch = _operationHandler.CreateOperation(context, path); @@ -140,7 +140,7 @@ public void CreateEntityPatchReturnsSecurityForUpdateRestrictions(bool enableAnn ODataContext context = new ODataContext(model); IEdmEntitySet customers = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(customers); // guard - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(customers), new ODataKeySegment(customers.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(customers), new ODataKeySegment(customers.EntityType)); // Act var patch = _operationHandler.CreateOperation(context, path); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityPutOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityPutOperationHandlerTests.cs index fb5f11c2..b3b67740 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityPutOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EntityPutOperationHandlerTests.cs @@ -32,7 +32,7 @@ public void CreateEntityPutOperationReturnsCorrectOperation(bool enableOperation UseSuccessStatusCodeRange = useHTTPStatusCodeClass2XX }; ODataContext context = new ODataContext(model, settings); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType)); // Act var putOperation = _operationHandler.CreateOperation(context, path); @@ -140,7 +140,7 @@ public void CreateEntityPutReturnsSecurityForUpdateRestrictions(bool enableAnnot ODataContext context = new ODataContext(model); IEdmEntitySet customers = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(customers); // guard - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(customers), new ODataKeySegment(customers.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(customers), new ODataKeySegment(customers.EntityType)); // Act var putOperation = _operationHandler.CreateOperation(context, path); @@ -185,9 +185,9 @@ public void CreateEntityPutOperationReturnsCorrectOperationWithAnnotatedRequestB OpenApiConvertSettings settings = new(); ODataContext context = new(model, settings); IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("directoryObjects"); - Assert.NotNull(entitySet); - - ODataPath path = new(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType())); + Assert.NotNull(entitySet); + + ODataPath path = new(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType)); // Act var operation = _operationHandler.CreateOperation(context, path); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/MediaEntityDeleteOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/MediaEntityDeleteOperationHandlerTests.cs index 6c78a45e..3819e89a 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/MediaEntityDeleteOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/MediaEntityDeleteOperationHandlerTests.cs @@ -26,7 +26,7 @@ public void CreateMediaEntityPropertyDeleteOperationWithTargetPathAnnotationsRet IEdmEntitySet people = model.EntityContainer.FindEntitySet("People"); Assert.NotNull(people); - IEdmEntityType person = people.EntityType(); + IEdmEntityType person = people.EntityType; IEdmStructuralProperty property = person.StructuralProperties().First(c => c.Name == "Photo"); ODataPath path = new(new ODataNavigationSourceSegment(people), new ODataKeySegment(person), @@ -105,13 +105,13 @@ private void VerifyMediaEntityDeleteOperation(string annotation, bool enableOper IEdmSingleton me = model.EntityContainer.FindSingleton("me"); Assert.NotNull(todos); - IEdmEntityType todo = todos.EntityType(); + IEdmEntityType todo = todos.EntityType; IEdmStructuralProperty structuralProperty = todo.StructuralProperties().First(c => c.Name == "Logo"); ODataPath path = new(new ODataNavigationSourceSegment(todos), new ODataKeySegment(todo), new ODataStreamPropertySegment(structuralProperty.Name)); - IEdmEntityType user = me.EntityType(); + IEdmEntityType user = me.EntityType; IEdmNavigationProperty navProperty = user.NavigationProperties().First(c => c.Name == "photo"); ODataPath path2 = new(new ODataNavigationSourceSegment(me), new ODataNavigationPropertySegment(navProperty), diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/MediaEntityGetOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/MediaEntityGetOperationHandlerTests.cs index b3e2ec18..09951b33 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/MediaEntityGetOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/MediaEntityGetOperationHandlerTests.cs @@ -71,7 +71,7 @@ private void VerifyMediaEntityGetOperation(string annotation, bool enableOperati IEdmEntityType todo = model.SchemaElements.OfType().First(c => c.Name == "Todo"); IEdmStructuralProperty sp = todo.StructuralProperties().First(c => c.Name == "Logo"); ODataPath path = new ODataPath(new ODataNavigationSourceSegment(todos), - new ODataKeySegment(todos.EntityType()), + new ODataKeySegment(todos.EntityType), new ODataStreamPropertySegment(sp.Name)); IEdmEntityType user = model.SchemaElements.OfType().First(c => c.Name == "user"); @@ -194,7 +194,7 @@ public void CreateMediaEntityPropertyGetOperationWithTargetPathAnnotationsReturn IEdmEntitySet people = model.EntityContainer.FindEntitySet("People"); Assert.NotNull(people); - IEdmEntityType person = people.EntityType(); + IEdmEntityType person = people.EntityType; IEdmStructuralProperty property = person.StructuralProperties().First(c => c.Name == "Photo"); ODataPath path = new (new ODataNavigationSourceSegment(people), new ODataKeySegment(person), diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/MediaEntityPutOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/MediaEntityPutOperationHandlerTests.cs index 5b68eceb..9dc2f99e 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/MediaEntityPutOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/MediaEntityPutOperationHandlerTests.cs @@ -69,7 +69,7 @@ private void VerifyMediaEntityPutOperation(string annotation, bool enableOperati IEdmEntityType todo = model.SchemaElements.OfType().First(c => c.Name == "Todo"); IEdmStructuralProperty sp = todo.StructuralProperties().First(c => c.Name == "Logo"); ODataPath path = new ODataPath(new ODataNavigationSourceSegment(todos), - new ODataKeySegment(todos.EntityType()), + new ODataKeySegment(todos.EntityType), new ODataStreamPropertySegment(sp.Name)); IEdmEntityType user = model.SchemaElements.OfType().First(c => c.Name == "user"); @@ -80,7 +80,7 @@ private void VerifyMediaEntityPutOperation(string annotation, bool enableOperati IEdmStructuralProperty sp2 = todo.StructuralProperties().First(c => c.Name == "Content"); ODataPath path3 = new(new ODataNavigationSourceSegment(todos), - new ODataKeySegment(todos.EntityType()), + new ODataKeySegment(todos.EntityType), new ODataStreamPropertySegment(sp2.Name)); // Act @@ -169,7 +169,7 @@ public void CreateMediaEntityPropertyPutOperationWithTargetPathAnnotationsReturn IEdmEntitySet people = model.EntityContainer.FindEntitySet("People"); Assert.NotNull(people); - IEdmEntityType person = people.EntityType(); + IEdmEntityType person = people.EntityType; IEdmStructuralProperty property = person.StructuralProperties().First(c => c.Name == "Photo"); ODataPath path = new(new ODataNavigationSourceSegment(people), new ODataKeySegment(person), diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyDeleteOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyDeleteOperationHandlerTests.cs index 3c97d8a1..3b4d65ed 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyDeleteOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyDeleteOperationHandlerTests.cs @@ -35,7 +35,7 @@ public void CreateNavigationDeleteOperationReturnsCorrectOperation(bool enableOp IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Trips"); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType()), new ODataNavigationPropertySegment(navProperty)); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty)); // Act var operation = _operationHandler.CreateOperation(context, path); @@ -77,7 +77,7 @@ public void CreateNavigationDeleteOperationWithTargetPathAnnotationsReturnsCorre IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Friends"); - ODataPath path = new(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType()), new ODataNavigationPropertySegment(navProperty)); + ODataPath path = new(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty)); // Act var operation = _operationHandler.CreateOperation(context, path); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyGetOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyGetOperationHandlerTests.cs index 5e6c401d..69463815 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyGetOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyGetOperationHandlerTests.cs @@ -38,7 +38,7 @@ public void CreateNavigationGetOperationReturnsCorrectOperation(bool enableOpera IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Trips"); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType()), new ODataNavigationPropertySegment(navProperty)); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty)); // Act var operation = _operationHandler.CreateOperation(context, path); @@ -81,7 +81,7 @@ public void CreateNavigationGetOperationWithTargetPathAnnotationsAndNavigationPr IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Friends"); - ODataPath path = new(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType()), new ODataNavigationPropertySegment(navProperty)); + ODataPath path = new(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty)); // Act var operation = _operationHandler.CreateOperation(context, path); @@ -101,34 +101,34 @@ public void CreateNavigationGetOperationWithTargetPathAnnotationsAndNavigationPr } [Fact] - public void CreateNavigationGetOperationViaComposableFunctionReturnsCorrectOperation() - { - // Arrange + public void CreateNavigationGetOperationViaComposableFunctionReturnsCorrectOperation() + { + // Arrange IEdmModel model = EdmModelHelper.GraphBetaModel; - ODataContext context = new(model, new OpenApiConvertSettings() + ODataContext context = new(model, new OpenApiConvertSettings() { EnableOperationId = true }); - IEdmEntitySet sites = model.EntityContainer.FindEntitySet("sites"); - IEdmEntityType site = model.SchemaElements.OfType().First(c => c.Name == "site"); - IEdmNavigationProperty analytics = site.DeclaredNavigationProperties().First(c => c.Name == "analytics"); - IEdmOperation getByPath = model.SchemaElements.OfType().First(f => f.Name == "getByPath"); - - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(sites), - new ODataKeySegment(site), - new ODataOperationSegment(getByPath), - new ODataNavigationPropertySegment(analytics)); - + IEdmEntitySet sites = model.EntityContainer.FindEntitySet("sites"); + IEdmEntityType site = model.SchemaElements.OfType().First(c => c.Name == "site"); + IEdmNavigationProperty analytics = site.DeclaredNavigationProperties().First(c => c.Name == "analytics"); + IEdmOperation getByPath = model.SchemaElements.OfType().First(f => f.Name == "getByPath"); + + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(sites), + new ODataKeySegment(site), + new ODataOperationSegment(getByPath), + new ODataNavigationPropertySegment(analytics)); + // Act - var operation = _operationHandler.CreateOperation(context, path); - - // Assert - Assert.NotNull(operation); - Assert.Equal("sites.getByPath.GetAnalytics", operation.OperationId); - Assert.NotNull(operation.Parameters); - Assert.Equal(4, operation.Parameters.Count); - Assert.Contains(operation.Parameters, x => x.Name == "path"); + var operation = _operationHandler.CreateOperation(context, path); + + // Assert + Assert.NotNull(operation); + Assert.Equal("sites.getByPath.GetAnalytics", operation.OperationId); + Assert.NotNull(operation.Parameters); + Assert.Equal(4, operation.Parameters.Count); + Assert.Contains(operation.Parameters, x => x.Name == "path"); } [Theory] @@ -209,7 +209,7 @@ public void CreateNavigationGetOperationReturnsSecurityForReadRestrictions(bool ODataContext context = new ODataContext(edmModel); IEdmEntitySet entitySet = edmModel.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - IEdmEntityType entityType = entitySet.EntityType(); + IEdmEntityType entityType = entitySet.EntityType; IEdmNavigationProperty property = entityType.DeclaredNavigationProperties().FirstOrDefault(c => c.Name == "Orders"); Assert.NotNull(property); @@ -275,33 +275,33 @@ public void CreateNavigationGetOperationReturnsSecurityForReadRestrictions(bool } [Fact] - public void CreateNavigationGetOperationWithAlternateKeyReturnsCorrectOperationId() - { - // Arrange + public void CreateNavigationGetOperationWithAlternateKeyReturnsCorrectOperationId() + { + // Arrange IEdmModel model = EdmModelHelper.GraphBetaModel; - ODataContext context = new(model, new OpenApiConvertSettings() + ODataContext context = new(model, new OpenApiConvertSettings() { - EnableOperationId = true + EnableOperationId = true }); - IEdmSingleton singleton = model.EntityContainer.FindSingleton("communications"); - IEdmEntityType entityType = model.SchemaElements.OfType().First(c => c.Name == "cloudCommunications"); - IEdmNavigationProperty navProp = entityType.DeclaredNavigationProperties().First(c => c.Name == "onlineMeetings"); - IDictionary keyMappings = new Dictionary { { "joinWebUrl", "joinWebUrl" } }; - - ODataPath path = new(new ODataNavigationSourceSegment(singleton), - new ODataNavigationPropertySegment(navProp), - new ODataKeySegment(entityType, keyMappings) - { - IsAlternateKey = true - }); - + IEdmSingleton singleton = model.EntityContainer.FindSingleton("communications"); + IEdmEntityType entityType = model.SchemaElements.OfType().First(c => c.Name == "cloudCommunications"); + IEdmNavigationProperty navProp = entityType.DeclaredNavigationProperties().First(c => c.Name == "onlineMeetings"); + IDictionary keyMappings = new Dictionary { { "joinWebUrl", "joinWebUrl" } }; + + ODataPath path = new(new ODataNavigationSourceSegment(singleton), + new ODataNavigationPropertySegment(navProp), + new ODataKeySegment(entityType, keyMappings) + { + IsAlternateKey = true + }); + // Act - var operation = _operationHandler.CreateOperation(context, path); - - // Assert - Assert.NotNull(operation); - Assert.Equal("communications.onlineMeetings.GetByJoinWebUrl", operation.OperationId); + var operation = _operationHandler.CreateOperation(context, path); + + // Assert + Assert.NotNull(operation); + Assert.Equal("communications.onlineMeetings.GetByJoinWebUrl", operation.OperationId); } } } diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyPatchOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyPatchOperationHandlerTests.cs index 78fc292c..9dad564b 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyPatchOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyPatchOperationHandlerTests.cs @@ -37,7 +37,7 @@ public void CreateNavigationPatchOperationReturnsCorrectOperation(bool enableOpe IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "BestFriend"); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType()), new ODataNavigationPropertySegment(navProperty)); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty)); // Act var operation = _operationHandler.CreateOperation(context, path); @@ -77,8 +77,8 @@ public void CreateNavigationPatchOperationReturnsCorrectOperation(bool enableOpe { Assert.Null(operation.OperationId); } - } - + } + [Fact] public void CreateNavigationPatchOperationReturnsCorrectOperationWithAnnotatedRequestBodyContent() { @@ -179,7 +179,7 @@ public void CreateNavigationPatchOperationReturnsSecurityForUpdateRestrictions(b ODataContext context = new ODataContext(edmModel); IEdmEntitySet entitySet = edmModel.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - IEdmEntityType entityType = entitySet.EntityType(); + IEdmEntityType entityType = entitySet.EntityType; IEdmNavigationProperty property = entityType.DeclaredNavigationProperties().FirstOrDefault(c => c.Name == "Orders"); Assert.NotNull(property); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyPostOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyPostOperationHandlerTests.cs index baba8625..47e23bd7 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyPostOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyPostOperationHandlerTests.cs @@ -37,7 +37,7 @@ public void CreateNavigationPostOperationReturnsCorrectOperation(bool enableOper IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Trips"); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType()), new ODataNavigationPropertySegment(navProperty)); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty)); // Act var operation = _operationHandler.CreateOperation(context, path); @@ -70,35 +70,35 @@ public void CreateNavigationPostOperationReturnsCorrectOperation(bool enableOper } } - [Fact] - public void CreateNavigationPostOperationWithTargetPathAnnotationsReturnsCorrectOperation() - { - // Arrange - IEdmModel model = EdmModelHelper.TripServiceModel; - ODataContext context = new(model, new OpenApiConvertSettings()); - IEdmEntitySet people = model.EntityContainer.FindEntitySet("People"); - Assert.NotNull(people); - - IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); - IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Friends"); - ODataPath path = new(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType()), new ODataNavigationPropertySegment(navProperty)); - - // Act - var operation = _operationHandler.CreateOperation(context, path); - - // Assert - Assert.NotNull(operation); - Assert.Equal("Create a friend.", operation.Summary); - Assert.Equal("Create a new friend.", operation.Description); - - Assert.NotNull(operation.ExternalDocs); - Assert.Equal("Find more info here", operation.ExternalDocs.Description); - Assert.Equal("https://learn.microsoft.com/graph/api/person-post-friend?view=graph-rest-1.0", operation.ExternalDocs.Url.ToString()); + [Fact] + public void CreateNavigationPostOperationWithTargetPathAnnotationsReturnsCorrectOperation() + { + // Arrange + IEdmModel model = EdmModelHelper.TripServiceModel; + ODataContext context = new(model, new OpenApiConvertSettings()); + IEdmEntitySet people = model.EntityContainer.FindEntitySet("People"); + Assert.NotNull(people); + + IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); + IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Friends"); + ODataPath path = new(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty)); + + // Act + var operation = _operationHandler.CreateOperation(context, path); + + // Assert + Assert.NotNull(operation); + Assert.Equal("Create a friend.", operation.Summary); + Assert.Equal("Create a new friend.", operation.Description); + + Assert.NotNull(operation.ExternalDocs); + Assert.Equal("Find more info here", operation.ExternalDocs.Description); + Assert.Equal("https://learn.microsoft.com/graph/api/person-post-friend?view=graph-rest-1.0", operation.ExternalDocs.Url.ToString()); } [Fact] - public void CreateNavigationPostOperationReturnsCorrectOperationWithAnnotatedRequestBodyContent() - { + public void CreateNavigationPostOperationReturnsCorrectOperationWithAnnotatedRequestBodyContent() + { IEdmModel model = EdmModelHelper.GraphBetaModel; OpenApiConvertSettings settings = new(); ODataContext context = new(model, settings); @@ -108,13 +108,13 @@ public void CreateNavigationPostOperationReturnsCorrectOperationWithAnnotatedReq IEdmNavigationProperty navProperty = entity.DeclaredNavigationProperties().First(c => c.Name == "apiConnectors"); ODataPath path = new(new ODataNavigationSourceSegment(sTon), new ODataNavigationPropertySegment(navProperty)); - + // Act - var operation = _operationHandler.CreateOperation(context, path); - - // Assert - Assert.NotNull(operation.RequestBody); - Assert.Equal("application/xhtml+xml", operation.RequestBody.Content.First().Key); + var operation = _operationHandler.CreateOperation(context, path); + + // Assert + Assert.NotNull(operation.RequestBody); + Assert.Equal("application/xhtml+xml", operation.RequestBody.Content.First().Key); } [Theory] @@ -196,7 +196,7 @@ public void CreateNavigationPostOperationReturnsSecurityForInsertRestrictions(bo ODataContext context = new ODataContext(edmModel); IEdmEntitySet entitySet = edmModel.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - IEdmEntityType entityType = entitySet.EntityType(); + IEdmEntityType entityType = entitySet.EntityType; IEdmNavigationProperty property = entityType.DeclaredNavigationProperties().FirstOrDefault(c => c.Name == "Orders"); Assert.NotNull(property); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyPutOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyPutOperationHandlerTests.cs index 499863bc..4f23fc41 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyPutOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/NavigationPropertyPutOperationHandlerTests.cs @@ -37,7 +37,7 @@ public void CreateNavigationPutOperationReturnsCorrectOperation(bool enableOpera IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "BestFriend"); - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType()), new ODataNavigationPropertySegment(navProperty)); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty)); // Act var operation = _operationHandler.CreateOperation(context, path); @@ -158,7 +158,7 @@ public void CreateNavigationPuthOperationReturnsSecurityForUpdateRestrictions(bo ODataContext context = new ODataContext(edmModel); IEdmEntitySet entitySet = edmModel.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - IEdmEntityType entityType = entitySet.EntityType(); + IEdmEntityType entityType = entitySet.EntityType; IEdmNavigationProperty property = entityType.DeclaredNavigationProperties().FirstOrDefault(c => c.Name == "Orders"); Assert.NotNull(property); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ODataTypeCastGetOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ODataTypeCastGetOperationHandlerTests.cs index cf5f392d..3a3e1109 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ODataTypeCastGetOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/ODataTypeCastGetOperationHandlerTests.cs @@ -38,7 +38,7 @@ public void CreateODataTypeCastGetOperationReturnsCorrectOperationForCollectionN IEdmEntityType employee = model.SchemaElements.OfType().First(c => c.Name == "Employee"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Friends"); ODataPath path = new(new ODataNavigationSourceSegment(people), - new ODataKeySegment(people.EntityType()), + new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty), new ODataTypeCastSegment(employee, model)); @@ -96,9 +96,9 @@ public void CreateODataTypeCastGetOperationReturnsCorrectOperationForCollectionN IEdmEntityType employee = model.SchemaElements.OfType().First(c => c.Name == "Employee"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Friends"); ODataPath path = new(new ODataNavigationSourceSegment(people), - new ODataKeySegment(people.EntityType()), + new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty), - new ODataKeySegment(people.EntityType()), + new ODataKeySegment(people.EntityType), new ODataTypeCastSegment(employee,model)); // Act @@ -206,7 +206,7 @@ public void CreateODataTypeCastGetOperationReturnsCorrectOperationForEntitySetId IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmEntityType employee = model.SchemaElements.OfType().First(c => c.Name == "Employee"); ODataPath path = new(new ODataNavigationSourceSegment(people), - new ODataKeySegment(people.EntityType()), + new ODataKeySegment(people.EntityType), new ODataTypeCastSegment(employee,model)); // Act @@ -262,7 +262,7 @@ public void CreateODataTypeCastGetOperationReturnsCorrectOperationForSingleNavig IEdmEntityType employee = model.SchemaElements.OfType().First(c => c.Name == "Employee"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "BestFriend"); ODataPath path = new(new ODataNavigationSourceSegment(people), - new ODataKeySegment(people.EntityType()), + new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty), new ODataTypeCastSegment(employee, model)); @@ -363,7 +363,7 @@ public void CreateODataTypeCastGetOperationReturnsCorrectOperationForSingleNavig IEdmEntityType manager = model.SchemaElements.OfType().First(c => c.Name == "Manager"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "BestFriend"); ODataPath path = new(new ODataNavigationSourceSegment(people), - new ODataKeySegment(people.EntityType()), + new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty), new ODataTypeCastSegment(manager, model)); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefDeleteOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefDeleteOperationHandlerTests.cs index 7221e62b..66cf5a13 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefDeleteOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefDeleteOperationHandlerTests.cs @@ -33,7 +33,7 @@ public void CreateNavigationRefDeleteOperationReturnsCorrectOperation(bool enabl IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Trips"); ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), - new ODataKeySegment(people.EntityType()), + new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty), ODataRefSegment.Instance); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefGetOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefGetOperationHandlerTests.cs index 1dfe9206..029b1f37 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefGetOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefGetOperationHandlerTests.cs @@ -36,7 +36,7 @@ public void CreateNavigationRefGetOperationReturnsCorrectOperation(bool enableOp IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Trips"); ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), - new ODataKeySegment(people.EntityType()), + new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty), ODataRefSegment.Instance); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefPostOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefPostOperationHandlerTests.cs index a5f1ba3f..1f0cd91e 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefPostOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefPostOperationHandlerTests.cs @@ -36,7 +36,7 @@ public void CreateNavigationRefPostOperationReturnsCorrectOperation(bool enableO IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Trips"); ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), - new ODataKeySegment(people.EntityType()), + new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty), ODataRefSegment.Instance); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefPutOperationHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefPutOperationHandlerTests.cs index 9a431561..7e734fe1 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefPutOperationHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/RefPutOperationHandlerTests.cs @@ -36,7 +36,7 @@ public void CreateNavigationRefPutOperationReturnsCorrectOperation(bool enableOp IEdmEntityType person = model.SchemaElements.OfType().First(c => c.Name == "Person"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "BestFriend"); ODataPath path = new ODataPath(new ODataNavigationSourceSegment(people), - new ODataKeySegment(people.EntityType()), + new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty), ODataRefSegment.Instance); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/ComplexPropertyPathItemHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/ComplexPropertyPathItemHandlerTests.cs index 391acd4b..02385b2e 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/ComplexPropertyPathItemHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/ComplexPropertyPathItemHandlerTests.cs @@ -53,7 +53,7 @@ public void SetsDefaultOperations(bool useAnnotationToGeneratePath, bool annotat var context = new ODataContext(model, convertSettings); var entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - var entityType = entitySet.EntityType(); + var entityType = entitySet.EntityType; var property = entityType.FindProperty("BillingAddress"); Assert.NotNull(property); // guard var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entityType), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); @@ -106,7 +106,7 @@ public void SetsUpdateOperationWithUpdateMethodUpdateRestrictions(bool useAnnota var context = new ODataContext(model, convertSettings); var entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - var entityType = entitySet.EntityType(); + var entityType = entitySet.EntityType; var property = entityType.FindProperty("BillingAddress"); Assert.NotNull(property); // guard var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entityType), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); @@ -164,7 +164,7 @@ public void SetsPostOnCollectionProperties(bool useAnnotationToGeneratePath, boo var context = new ODataContext(model, convertSettings); var entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - var entityType = entitySet.EntityType(); + var entityType = entitySet.EntityType; var property = entityType.FindProperty("AlternativeAddresses"); Assert.NotNull(property); // guard var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entityType), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); @@ -191,7 +191,7 @@ public void CreateComplexPropertyPathItemAddsCustomAttributeValuesToPathExtensio context.Settings.CustomXMLAttributesMapping.Add("ags:IsHidden", "x-ms-isHidden"); var entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - var entityType = entitySet.EntityType(); + var entityType = entitySet.EntityType; var property = entityType.FindProperty("AlternativeAddresses"); Assert.NotNull(property); // guard var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entityType), new ODataComplexPropertySegment(property as IEdmStructuralProperty)); @@ -238,7 +238,7 @@ public void CreatesComplexPropertyPathsBasedOnTargetPathAnnotations(string reada var entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - var entityType = entitySet.EntityType(); + var entityType = entitySet.EntityType; var property = entityType.FindProperty("AlternativeAddresses"); Assert.NotNull(property); // guard diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/EntityPathItemHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/EntityPathItemHandlerTests.cs index f5a060a8..5a946926 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/EntityPathItemHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/EntityPathItemHandlerTests.cs @@ -63,7 +63,7 @@ public void CreateEntityPathItemReturnsCorrectPathItem() ODataContext context = new ODataContext(model); IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType)); // Act var pathItem = _pathItemHandler.CreatePathItem(context, path); @@ -92,7 +92,7 @@ public void CreateEntityPathItemReturnsCorrectPathItemWithPathParameters(bool de ODataContext context = new ODataContext(model, convertSettings); IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType)); // Act var pathItem = _pathItemHandler.CreatePathItem(context, path); @@ -127,7 +127,7 @@ public void CreateEntityPathItemReturnsCorrectPathItemWithReferences() ODataContext context = new ODataContext(model); IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType)); // Act var pathItem = _pathItemHandler.CreatePathItem(context, path); @@ -241,7 +241,7 @@ private void VerifyPathItemOperations(string annotation, OperationType[] expecte ODataContext context = new ODataContext(model); IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType())); + ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType)); // Act var pathItem = _pathItemHandler.CreatePathItem(context, path); @@ -271,7 +271,7 @@ public void CreateEntityPathItemAddsCustomAttributeValuesToPathExtensions() }; IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - ODataPath path = new(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType())); + ODataPath path = new(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType)); // Act var pathItem = _pathItemHandler.CreatePathItem(context, path); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/EntitySetPathItemHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/EntitySetPathItemHandlerTests.cs index 5d907295..8be197a4 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/EntitySetPathItemHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/EntitySetPathItemHandlerTests.cs @@ -46,7 +46,7 @@ public void CreatePathItemThrowsForNonEntitySetPath() ODataContext context = new ODataContext(model); var entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType())); + var path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType)); Assert.Equal(ODataPathKind.Entity, path.Kind); // guard // Act diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/MediaEntityPathItemHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/MediaEntityPathItemHandlerTests.cs index dd7ac1b1..7ed6f8d8 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/MediaEntityPathItemHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/MediaEntityPathItemHandlerTests.cs @@ -63,7 +63,7 @@ public void CreateMediaEntityPathItemReturnsCorrectItem() IEdmSingleton singleton = model.EntityContainer.FindSingleton("me"); Assert.NotNull(entitySet); // guard Assert.NotNull(singleton); - IEdmEntityType entityType = entitySet.EntityType(); + IEdmEntityType entityType = entitySet.EntityType; IEdmStructuralProperty sp = entityType.DeclaredStructuralProperties().First(c => c.Name == "Logo"); ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), @@ -217,7 +217,7 @@ private void VerifyPathItemOperationsForStreamPropertySegment(string annotation, ODataContext context = new ODataContext(model); IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("Todos"); Assert.NotNull(entitySet); // guard - IEdmEntityType entityType = entitySet.EntityType(); + IEdmEntityType entityType = entitySet.EntityType; IEdmStructuralProperty sp = entityType.DeclaredStructuralProperties().First(c => c.Name == "Logo"); ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), @@ -244,7 +244,7 @@ private void VerifyPathItemOperationsForStreamContentSegment(string annotation, IEdmSingleton singleton = model.EntityContainer.FindSingleton("me"); Assert.NotNull(entitySet); // guard Assert.NotNull(singleton); - IEdmEntityType entityType = entitySet.EntityType(); + IEdmEntityType entityType = entitySet.EntityType; IEdmEntityType user = model.SchemaElements.OfType().First(c => c.Name == "user"); IEdmNavigationProperty navProperty = user.DeclaredNavigationProperties().First(c => c.Name == "photo"); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/NavigationPropertyPathItemHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/NavigationPropertyPathItemHandlerTests.cs index 66aedac9..20e9c066 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/NavigationPropertyPathItemHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/NavigationPropertyPathItemHandlerTests.cs @@ -80,7 +80,7 @@ public void CreateCollectionNavigationPropertyPathItemReturnsCorrectPathItem(boo ODataContext context = new ODataContext(model); IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - IEdmEntityType entityType = entitySet.EntityType(); + IEdmEntityType entityType = entitySet.EntityType; IEdmNavigationProperty property = entityType.DeclaredNavigationProperties() .FirstOrDefault(c => c.ContainsTarget == containment && c.TargetMultiplicity() == EdmMultiplicity.Many); @@ -123,7 +123,7 @@ public void CreateNavigationPropertyPathItemReturnsCorrectPathItemWithPathParame ODataContext context = new ODataContext(model, settings); IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - IEdmEntityType entityType = entitySet.EntityType(); + IEdmEntityType entityType = entitySet.EntityType; IEdmNavigationProperty property = entityType.DeclaredNavigationProperties() .FirstOrDefault(c => c.ContainsTarget == true && c.TargetMultiplicity() == EdmMultiplicity.Many); @@ -176,7 +176,7 @@ public void CreateSingleNavigationPropertyPathItemReturnsCorrectPathItem(bool co ODataContext context = new ODataContext(model); IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - IEdmEntityType entityType = entitySet.EntityType(); + IEdmEntityType entityType = entitySet.EntityType; IEdmNavigationProperty property = entityType.DeclaredNavigationProperties() .FirstOrDefault(c => c.ContainsTarget == containment && c.TargetMultiplicity() != EdmMultiplicity.Many); @@ -661,7 +661,7 @@ private static ODataPath CreatePath(IEdmNavigationSource navigationSource, strin Assert.NotNull(navigationSource); Assert.NotNull(navigationPropertyPath); - IEdmEntityType previousEntityType = navigationSource.EntityType(); + IEdmEntityType previousEntityType = navigationSource.EntityType; ODataPath path = new ODataPath(new ODataNavigationSourceSegment(navigationSource), new ODataKeySegment(previousEntityType)); string[] npPaths = navigationPropertyPath.Split('/'); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/ODataTypeCastPathItemHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/ODataTypeCastPathItemHandlerTests.cs index 8a543722..29fa676c 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/ODataTypeCastPathItemHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/ODataTypeCastPathItemHandlerTests.cs @@ -42,7 +42,7 @@ public void CreateODataTypeCastPathItemAddsCustomAttributeValuesToPathExtensions IEdmEntityType employee = model.SchemaElements.OfType().First(c => c.Name == "Employee"); IEdmNavigationProperty navProperty = person.DeclaredNavigationProperties().First(c => c.Name == "Friends"); ODataPath path = new(new ODataNavigationSourceSegment(people), - new ODataKeySegment(people.EntityType()), + new ODataKeySegment(people.EntityType), new ODataNavigationPropertySegment(navProperty), new ODataTypeCastSegment(employee, model)); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/RefPathItemHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/RefPathItemHandlerTests.cs index 025afeb6..87857046 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/RefPathItemHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/RefPathItemHandlerTests.cs @@ -67,7 +67,7 @@ public void CreateNavigationPropertyRefPathItemReturnsCorrectPathItem(bool colle ODataContext context = new ODataContext(model); IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("Customers"); Assert.NotNull(entitySet); // guard - IEdmEntityType entityType = entitySet.EntityType(); + IEdmEntityType entityType = entitySet.EntityType; IEdmNavigationProperty property = entityType.DeclaredNavigationProperties() .FirstOrDefault(c => !c.ContainsTarget && From 59d83f19ae1b0f58d39d4ac1d9556bc0533d758d Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 15 Aug 2024 09:32:42 -0400 Subject: [PATCH 05/10] chore: updates shipped APIs Signed-off-by: Vincent Biret --- .../PublicAPI.Unshipped.txt | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/src/Microsoft.OpenApi.OData.Reader/PublicAPI.Unshipped.txt b/src/Microsoft.OpenApi.OData.Reader/PublicAPI.Unshipped.txt index f94e5952..eb93babf 100644 --- a/src/Microsoft.OpenApi.OData.Reader/PublicAPI.Unshipped.txt +++ b/src/Microsoft.OpenApi.OData.Reader/PublicAPI.Unshipped.txt @@ -35,8 +35,6 @@ Microsoft.OpenApi.OData.OpenApiConvertSettings.EnableODataAnnotationReferencesFo Microsoft.OpenApi.OData.OpenApiConvertSettings.EnableODataAnnotationReferencesForResponses.set -> void Microsoft.OpenApi.OData.OpenApiConvertSettings.EnableTypeDisambiguationForDefaultValueOfOdataTypeProperty.get -> bool Microsoft.OpenApi.OData.OpenApiConvertSettings.EnableTypeDisambiguationForDefaultValueOfOdataTypeProperty.set -> void -Microsoft.OpenApi.OData.OpenApiConvertSettings.ExpandDerivedTypesNavigationProperties.get -> bool -Microsoft.OpenApi.OData.OpenApiConvertSettings.ExpandDerivedTypesNavigationProperties.set -> void Microsoft.OpenApi.OData.OpenApiConvertSettings.CustomXMLAttributesMapping.get -> System.Collections.Generic.Dictionary Microsoft.OpenApi.OData.OpenApiConvertSettings.CustomXMLAttributesMapping.set -> void Microsoft.OpenApi.OData.OpenApiConvertSettings.GenerateDerivedTypesProperties.get -> bool @@ -45,7 +43,6 @@ Microsoft.OpenApi.OData.OpenApiConvertSettings.IncludeAssemblyInfo.get -> bool Microsoft.OpenApi.OData.OpenApiConvertSettings.IncludeAssemblyInfo.set -> void Microsoft.OpenApi.OData.OpenApiConvertSettings.NamespacePrefixToStripForInMethodPaths.get -> string Microsoft.OpenApi.OData.OpenApiConvertSettings.NamespacePrefixToStripForInMethodPaths.set -> void -Microsoft.OpenApi.OData.OpenApiConvertSettings.RefBaseCollectionPaginationCountResponse.get -> bool Microsoft.OpenApi.OData.OpenApiConvertSettings.RequireRestrictionAnnotationsToGenerateComplexPropertyPaths.get -> bool Microsoft.OpenApi.OData.OpenApiConvertSettings.RequireRestrictionAnnotationsToGenerateComplexPropertyPaths.set -> void Microsoft.OpenApi.OData.OpenApiConvertSettings.SemVerVersion.get -> string @@ -56,11 +53,6 @@ Microsoft.OpenApi.OData.OpenApiConvertSettings.UseStringArrayForQueryOptionsSche Microsoft.OpenApi.OData.OpenApiConvertSettings.UseStringArrayForQueryOptionsSchema.set -> void Microsoft.OpenApi.OData.OpenApiConvertSettings.UseSuccessStatusCodeRange.get -> bool Microsoft.OpenApi.OData.OpenApiConvertSettings.UseSuccessStatusCodeRange.set -> void -Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiEnumFlagsExtension -Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiEnumFlagsExtension.Name.get -> string -Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiEnumFlagsExtension.OpenApiEnumFlagsExtension() -> void -Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiPrimaryErrorMessageExtension -Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiPrimaryErrorMessageExtension.OpenApiPrimaryErrorMessageExtension() -> void Microsoft.OpenApi.OData.Vocabulary.Core.LinkRelKey Microsoft.OpenApi.OData.Vocabulary.Core.LinkRelKey.Action = 6 -> Microsoft.OpenApi.OData.Vocabulary.Core.LinkRelKey Microsoft.OpenApi.OData.Vocabulary.Core.LinkRelKey.Create = 2 -> Microsoft.OpenApi.OData.Vocabulary.Core.LinkRelKey @@ -243,8 +235,6 @@ Microsoft.OpenApi.OData.OpenApiConvertSettings.TopExample.get -> int Microsoft.OpenApi.OData.OpenApiConvertSettings.TopExample.set -> void Microsoft.OpenApi.OData.OpenApiConvertSettings.VerifyEdmModel.get -> bool Microsoft.OpenApi.OData.OpenApiConvertSettings.VerifyEdmModel.set -> void -Microsoft.OpenApi.OData.OpenApiConvertSettings.Version.get -> System.Version -Microsoft.OpenApi.OData.OpenApiConvertSettings.Version.set -> void Microsoft.OpenApi.OData.OpenApiConvertSettings.EnableDeprecationInformation.get -> bool Microsoft.OpenApi.OData.OpenApiConvertSettings.EnableDeprecationInformation.set -> void Microsoft.OpenApi.OData.OpenApiConvertSettings.AddEnumDescriptionExtension.get -> bool @@ -310,7 +300,6 @@ static Microsoft.OpenApi.OData.Common.Utils.UpperFirstChar(string input) -> stri static Microsoft.OpenApi.OData.Edm.EdmModelExtensions.FindAllBaseTypes(this Microsoft.OData.Edm.IEdmEntityType entityType) -> System.Collections.Generic.IEnumerable static Microsoft.OpenApi.OData.Edm.EdmModelExtensions.FindAllBaseTypes(this Microsoft.OData.Edm.IEdmComplexType complexType) -> System.Collections.Generic.IEnumerable static Microsoft.OpenApi.OData.Edm.EdmModelExtensions.GetAllElements(this Microsoft.OData.Edm.IEdmModel model) -> System.Collections.Generic.IEnumerable -static Microsoft.OpenApi.OData.Edm.EdmModelExtensions.IsAssignableFrom(this Microsoft.OData.Edm.IEdmEntityType baseType, Microsoft.OData.Edm.IEdmEntityType subtype) -> bool static Microsoft.OpenApi.OData.Edm.EdmModelExtensions.IsOperationImportOverload(this Microsoft.OData.Edm.IEdmModel model, Microsoft.OData.Edm.IEdmOperationImport operationImport) -> bool static Microsoft.OpenApi.OData.Edm.EdmModelExtensions.IsOperationOverload(this Microsoft.OData.Edm.IEdmModel model, Microsoft.OData.Edm.IEdmOperation operation) -> bool static Microsoft.OpenApi.OData.Edm.EdmModelExtensions.IsUrlEscapeFunction(this Microsoft.OData.Edm.IEdmModel model, Microsoft.OData.Edm.IEdmFunction function) -> bool @@ -324,13 +313,4 @@ virtual Microsoft.OpenApi.OData.Edm.ODataPathProvider.CanFilter(Microsoft.OData. virtual Microsoft.OpenApi.OData.Edm.ODataPathProvider.GetPaths(Microsoft.OData.Edm.IEdmModel model, Microsoft.OpenApi.OData.OpenApiConvertSettings settings) -> System.Collections.Generic.IEnumerable virtual Microsoft.OpenApi.OData.Edm.ODataPathProvider.Initialize(Microsoft.OData.Edm.IEdmModel model) -> void virtual Microsoft.OpenApi.OData.Edm.ODataSegment.EntityType.get -> Microsoft.OData.Edm.IEdmEntityType -Microsoft.OpenApi.OData.Edm.ODataSegment.Deprecation.get -> Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiDeprecationExtension -Microsoft.OpenApi.OData.Edm.ODataSegment.Deprecation.set -> void -Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiDeprecationExtension -Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiDeprecationExtension.OpenApiDeprecationExtension() -> void -Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiDeprecationExtension.Name.get -> string -Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiDeprecationExtension.RemovalDate.get -> System.DateTime? -Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiDeprecationExtension.RemovalDate.set -> void -Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiDeprecationExtension.Date.get -> System.DateTime? -Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiDeprecationExtension.Date.set -> void Microsoft.OpenApi.OData.Common.OpenApiOperationExtensions From 003ed26d930afdcc4c6d8e5b5b340832ae03008e Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 15 Aug 2024 09:34:48 -0400 Subject: [PATCH 06/10] fix: replaces calls to extension method by property Signed-off-by: Vincent Biret --- .../Common/EdmModelHelper.cs | 66 +++--- .../Common/Utils.cs | 4 +- .../Edm/EdmAnnotationExtensions.cs | 10 +- .../Edm/EdmModelExtensions.cs | 8 +- .../Edm/ODataNavigationSourceSegment.cs | 2 +- .../Edm/ODataPathProvider.cs | 12 +- .../Generator/OpenApiParameterGenerator.cs | 220 +++++++++--------- .../Generator/OpenApiSchemaGenerator.cs | 2 +- .../DollarCountGetOperationHandler.cs | 2 +- .../Operation/EntityDeleteOperationHandler.cs | 2 +- .../Operation/EntityGetOperationHandler.cs | 8 +- .../Operation/EntitySetGetOperationHandler.cs | 10 +- .../Operation/EntitySetOperationHandler.cs | 2 +- .../EntitySetPostOperationHandler.cs | 60 ++--- .../Operation/EntityUpdateOperationHandler.cs | 16 +- .../ODataTypeCastGetOperationHandler.cs | 18 +- .../Operation/SingletonGetOperationHandler.cs | 8 +- .../Operation/SingletonOperationHandler.cs | 2 +- .../SingletonPatchOperationHandler.cs | 6 +- .../PathItem/EntityPathItemHandler.cs | 2 +- .../PathItem/EntitySetPathItemHandler.cs | 2 +- .../PathItem/MediaEntityPathItemHandler.cs | 2 +- .../PathItem/RefPathItemHandler.cs | 2 +- .../PathItem/SingletonPathItemHandler.cs | 2 +- 24 files changed, 234 insertions(+), 234 deletions(-) diff --git a/src/Microsoft.OpenApi.OData.Reader/Common/EdmModelHelper.cs b/src/Microsoft.OpenApi.OData.Reader/Common/EdmModelHelper.cs index d636fa0d..f4ade9d9 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Common/EdmModelHelper.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Common/EdmModelHelper.cs @@ -189,22 +189,22 @@ s is ODataOperationSegment || previousTypeCastSegmentId = "As" + Utils.UpperFirstChar(schemaElement.Name); items.Add(previousTypeCastSegmentId); } - else if (segment is ODataOperationSegment operationSegment) - { - // Navigation property generated via composable function - items.Add(operationSegment.Identifier); + else if (segment is ODataOperationSegment operationSegment) + { + // Navigation property generated via composable function + items.Add(operationSegment.Identifier); } - else if (segment is ODataKeySegment keySegment && keySegment.IsAlternateKey) - { - // We'll consider alternate keys in the operation id to eliminate potential duplicates with operation id of primary path - if (segment == segments.Last()) - { - items.Add("By" + string.Join("", keySegment.Identifier.Split(',').Select(static x => Utils.UpperFirstChar(x)))); - } - else - { - items.Add(keySegment.Identifier); - } + else if (segment is ODataKeySegment keySegment && keySegment.IsAlternateKey) + { + // We'll consider alternate keys in the operation id to eliminate potential duplicates with operation id of primary path + if (segment == segments.Last()) + { + items.Add("By" + string.Join("", keySegment.Identifier.Split(',').Select(static x => Utils.UpperFirstChar(x)))); + } + else + { + items.Add(keySegment.Identifier); + } } } @@ -366,29 +366,29 @@ internal static string GenerateODataTypeCastPathOperationIdPrefix(ODataPath path } else if (secondLastSegment is ODataKeySegment keySegment) { - if (isIndexedCollValuedNavProp) - { - operationId = GenerateNavigationPropertyPathOperationId(path, "Get"); + if (isIndexedCollValuedNavProp) + { + operationId = GenerateNavigationPropertyPathOperationId(path, "Get"); + } + else + { + string entityTypeName = keySegment.EntityType.Name; + string getPrefix = includeListOrGetPrefix ? "Get" : null; + string operationName = $"{getPrefix}{Utils.UpperFirstChar(entityTypeName)}"; + if (keySegment.IsAlternateKey) + { + string alternateKeyName = string.Join("", keySegment.Identifier.Split(',').Select(static x => Utils.UpperFirstChar(x))); + operationName = $"{operationName}By{alternateKeyName}"; + } + operationId = (entitySet != null) ? entitySet.Name : singleton.Name; + operationId += $".{entityTypeName}.{operationName}"; } - else - { - string entityTypeName = keySegment.EntityType.Name; - string getPrefix = includeListOrGetPrefix ? "Get" : null; - string operationName = $"{getPrefix}{Utils.UpperFirstChar(entityTypeName)}"; - if (keySegment.IsAlternateKey) - { - string alternateKeyName = string.Join("", keySegment.Identifier.Split(',').Select(static x => Utils.UpperFirstChar(x))); - operationName = $"{operationName}By{alternateKeyName}"; - } - operationId = (entitySet != null) ? entitySet.Name : singleton.Name; - operationId += $".{entityTypeName}.{operationName}"; - } } else if (secondLastSegment is ODataNavigationSourceSegment) { operationId = (entitySet != null) - ? entitySet.Name + "." + entitySet.EntityType().Name + $".{(includeListOrGetPrefix ? "List" : null)}" + Utils.UpperFirstChar(entitySet.EntityType().Name) - : singleton.Name + "." + singleton.EntityType().Name + $".{(includeListOrGetPrefix ? "Get" : null)}" + Utils.UpperFirstChar(singleton.EntityType().Name); + ? entitySet.Name + "." + entitySet.EntityType.Name + $".{(includeListOrGetPrefix ? "List" : null)}" + Utils.UpperFirstChar(entitySet.EntityType.Name) + : singleton.Name + "." + singleton.EntityType.Name + $".{(includeListOrGetPrefix ? "Get" : null)}" + Utils.UpperFirstChar(singleton.EntityType.Name); } return operationId; diff --git a/src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs b/src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs index f14013a6..d653de0e 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs @@ -261,9 +261,9 @@ internal static IEdmEntityType EntityTypeFromPathSegment(this ODataSegment segme case ODataNavigationPropertySegment navPropSegment: return navPropSegment.EntityType; case ODataNavigationSourceSegment navSourceSegment when navSourceSegment.NavigationSource is IEdmEntitySet entitySet: - return entitySet.EntityType(); + return entitySet.EntityType; case ODataNavigationSourceSegment navSourceSegment when navSourceSegment.NavigationSource is IEdmSingleton singleton: - return singleton.EntityType(); + return singleton.EntityType; case ODataKeySegment keySegment: return keySegment.EntityType; case ODataOperationSegment: diff --git a/src/Microsoft.OpenApi.OData.Reader/Edm/EdmAnnotationExtensions.cs b/src/Microsoft.OpenApi.OData.Reader/Edm/EdmAnnotationExtensions.cs index 1568fa79..97ed1cb6 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Edm/EdmAnnotationExtensions.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Edm/EdmAnnotationExtensions.cs @@ -57,7 +57,7 @@ internal static class EdmVocabularyAnnotationExtensions IEdmNavigationSource navigationSource = target as IEdmNavigationSource; if (navigationSource != null) { - IEdmEntityType entityType = navigationSource.EntityType(); + IEdmEntityType entityType = navigationSource.EntityType; value = model.GetBoolean(entityType, term); } } @@ -109,7 +109,7 @@ public static string GetString(this IEdmModel model, IEdmVocabularyAnnotatable t IEdmNavigationSource navigationSource = target as IEdmNavigationSource; if (navigationSource != null) { - IEdmEntityType entityType = navigationSource.EntityType(); + IEdmEntityType entityType = navigationSource.EntityType; value = model.GetString(entityType, term); } } @@ -165,7 +165,7 @@ public static T GetRecord(this IEdmModel model, IEdmVocabularyAnnotatable tar IEdmNavigationSource navigationSource = target as IEdmNavigationSource; if (navigationSource != null) { - IEdmEntityType entityType = navigationSource.EntityType(); + IEdmEntityType entityType = navigationSource.EntityType; value = model.GetRecord(entityType, term); } } @@ -226,7 +226,7 @@ public static IEnumerable GetCollection(this IEdmModel model, IEdmVocabu IEdmNavigationSource navigationSource = target as IEdmNavigationSource; if (navigationSource != null) { - IEdmEntityType entityType = navigationSource.EntityType(); + IEdmEntityType entityType = navigationSource.EntityType; value = model.GetCollection(entityType, term); } } @@ -282,7 +282,7 @@ public static IEnumerable GetCollection(this IEdmModel model, IEdmVocabula IEdmNavigationSource navigationSource = target as IEdmNavigationSource; if (navigationSource != null) { - IEdmEntityType entityType = navigationSource.EntityType(); + IEdmEntityType entityType = navigationSource.EntityType; value = model.GetCollection(entityType, term); } } diff --git a/src/Microsoft.OpenApi.OData.Reader/Edm/EdmModelExtensions.cs b/src/Microsoft.OpenApi.OData.Reader/Edm/EdmModelExtensions.cs index c74a782e..b7dc5351 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Edm/EdmModelExtensions.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Edm/EdmModelExtensions.cs @@ -80,10 +80,10 @@ public static IDictionary> LoadAllNa { Action>> action = (ns, dic) => { - if (!dic.TryGetValue(ns.EntityType(), out IList value)) + if (!dic.TryGetValue(ns.EntityType, out IList value)) { value = new List(); - dic[ns.EntityType()] = value; + dic[ns.EntityType] = value; } value.Add(ns); @@ -178,8 +178,8 @@ public static bool OperationTargetsMultiplePaths(this IEdmModel model, IEdmOpera IEdmTypeReference bindingParameterType = operation.Parameters.First().Type; - return model.EntityContainer.EntitySets().Select(static x => x.EntityType()) - .Concat(model.EntityContainer.Singletons().Select(static x => x.EntityType())) + return model.EntityContainer.EntitySets().Select(static x => x.EntityType) + .Concat(model.EntityContainer.Singletons().Select(static x => x.EntityType)) .Where(x => x.FullName().Equals(bindingParameterType.FullName(), StringComparison.OrdinalIgnoreCase)).Count() > 1; } diff --git a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataNavigationSourceSegment.cs b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataNavigationSourceSegment.cs index cb133b5a..8981af68 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataNavigationSourceSegment.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataNavigationSourceSegment.cs @@ -31,7 +31,7 @@ public ODataNavigationSourceSegment(IEdmNavigationSource navigationSource) public IEdmNavigationSource NavigationSource { get; } /// - public override IEdmEntityType EntityType => NavigationSource.EntityType(); + public override IEdmEntityType EntityType => NavigationSource.EntityType; /// public override string Identifier { get => NavigationSource.Name; } diff --git a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs index 0c5a17fb..ca56a177 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs @@ -243,7 +243,7 @@ private void RetrieveNavigationSourcePaths(IEdmNavigationSource navigationSource AppendPath(path.Clone()); IEdmEntitySet entitySet = navigationSource as IEdmEntitySet; - IEdmEntityType entityType = navigationSource.EntityType(); + IEdmEntityType entityType = navigationSource.EntityType; CountRestrictionsType count = null; bool? indexableByKey = false; @@ -923,14 +923,14 @@ private List GetAllEntitiesForOperation(IEdmTypeReference bindin var firstEntityType = bindingType.AsEntity().EntityDefinition(); bool filter(IEdmNavigationSource z) => - z.EntityType() != firstEntityType && - z.EntityType().FindAllBaseTypes().Contains(firstEntityType); + z.EntityType != firstEntityType && + z.EntityType.FindAllBaseTypes().Contains(firstEntityType); return new IEdmEntityType[] { firstEntityType } .Union(_model.EntityContainer.EntitySets() - .Where(filter).Select(x => x.EntityType())) //Search all EntitySets + .Where(filter).Select(x => x.EntityType)) //Search all EntitySets .Union(_model.EntityContainer.Singletons() - .Where(filter).Select(x => x.EntityType())) //Search all singletons + .Where(filter).Select(x => x.EntityType)) //Search all singletons .Distinct() .ToList(); } @@ -1082,7 +1082,7 @@ private void AppendBoundOperationOnDerived( } else { - ODataPath newPath = new ODataPath(new ODataNavigationSourceSegment(ns), new ODataKeySegment(ns.EntityType()), + ODataPath newPath = new ODataPath(new ODataNavigationSourceSegment(ns), new ODataKeySegment(ns.EntityType), new ODataTypeCastSegment(bindingEntityType , _model), new ODataOperationSegment(edmOperation, isEscapedFunction, _model)); AppendPath(newPath); diff --git a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiParameterGenerator.cs b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiParameterGenerator.cs index 39e152c5..eaceb870 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiParameterGenerator.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiParameterGenerator.cs @@ -292,27 +292,27 @@ public static List CreatePathParameters(this ODataPath path, O pathParameters.AddRange(context.CreateKeyParameters(keySegment, mapping)); } - foreach (ODataOperationSegment operationSegment in path.OfType()) - { + foreach (ODataOperationSegment operationSegment in path.OfType()) + { if (operationSegment.Operation is not IEdmFunction function) { continue; - } - - if (operationSegment.ParameterMappings != null) - { - IList parameters = context.CreateParameters(function, operationSegment.ParameterMappings); - foreach (var parameter in parameters) - { - pathParameters.AppendParameter(parameter); - } - } - else - { - IDictionary mappings = parameterMappings[operationSegment]; - IList parameters = context.CreateParameters(function, mappings); - pathParameters.AddRange(parameters); - } + } + + if (operationSegment.ParameterMappings != null) + { + IList parameters = context.CreateParameters(function, operationSegment.ParameterMappings); + foreach (var parameter in parameters) + { + pathParameters.AppendParameter(parameter); + } + } + else + { + IDictionary mappings = parameterMappings[operationSegment]; + IList parameters = context.CreateParameters(function, mappings); + pathParameters.AddRange(parameters); + } } // Add the route prefix parameter v1{data} @@ -372,19 +372,19 @@ public static OpenApiParameter CreateTop(this ODataContext context, IEdmVocabula return null; } - /// - /// Create the $top parameter for Edm target path. - /// - /// The OData context. - /// The string representation of the Edm target path. + /// + /// Create the $top parameter for Edm target path. + /// + /// The OData context. + /// The string representation of the Edm target path. /// public static OpenApiParameter CreateTop(this ODataContext context, string targetPath) { Utils.CheckArgumentNull(context, nameof(context)); - Utils.CheckArgumentNull(targetPath, nameof(targetPath)); - - IEdmTargetPath target = context.Model.GetTargetPath(targetPath); - if (target == null) + Utils.CheckArgumentNull(targetPath, nameof(targetPath)); + + IEdmTargetPath target = context.Model.GetTargetPath(targetPath); + if (target == null) return null; return context.CreateTop(target); @@ -414,19 +414,19 @@ public static OpenApiParameter CreateSkip(this ODataContext context, IEdmVocabul return null; } - /// - /// Create the $skip parameter for Edm target path. - /// - /// The OData context. - /// The string representation of the Edm target path. + /// + /// Create the $skip parameter for Edm target path. + /// + /// The OData context. + /// The string representation of the Edm target path. /// public static OpenApiParameter CreateSkip(this ODataContext context, string targetPath) { Utils.CheckArgumentNull(context, nameof(context)); - Utils.CheckArgumentNull(targetPath, nameof(targetPath)); - - IEdmTargetPath target = context.Model.GetTargetPath(targetPath); - if (target == null) + Utils.CheckArgumentNull(targetPath, nameof(targetPath)); + + IEdmTargetPath target = context.Model.GetTargetPath(targetPath); + if (target == null) return null; return context.CreateSkip(target); @@ -455,19 +455,19 @@ public static OpenApiParameter CreateSearch(this ODataContext context, IEdmVocab return null; } - /// - /// Create the $search parameter for Edm target path. - /// - /// The OData context. - /// The string representation of the Edm target path. + /// + /// Create the $search parameter for Edm target path. + /// + /// The OData context. + /// The string representation of the Edm target path. /// public static OpenApiParameter CreateSearch(this ODataContext context, string targetPath) { Utils.CheckArgumentNull(context, nameof(context)); - Utils.CheckArgumentNull(targetPath, nameof(targetPath)); - - IEdmTargetPath target = context.Model.GetTargetPath(targetPath); - if (target == null) + Utils.CheckArgumentNull(targetPath, nameof(targetPath)); + + IEdmTargetPath target = context.Model.GetTargetPath(targetPath); + if (target == null) return null; return context.CreateSearch(target); @@ -497,19 +497,19 @@ public static OpenApiParameter CreateCount(this ODataContext context, IEdmVocabu return null; } - /// - /// Create the $count parameter for Edm target path. - /// - /// The OData context. - /// The string representation of the Edm target path. + /// + /// Create the $count parameter for Edm target path. + /// + /// The OData context. + /// The string representation of the Edm target path. /// public static OpenApiParameter CreateCount(this ODataContext context, string targetPath) { Utils.CheckArgumentNull(context, nameof(context)); - Utils.CheckArgumentNull(targetPath, nameof(targetPath)); - - IEdmTargetPath target = context.Model.GetTargetPath(targetPath); - if (target == null) + Utils.CheckArgumentNull(targetPath, nameof(targetPath)); + + IEdmTargetPath target = context.Model.GetTargetPath(targetPath); + if (target == null) return null; return context.CreateCount(target); @@ -539,19 +539,19 @@ public static OpenApiParameter CreateFilter(this ODataContext context, IEdmVocab return null; } - /// - /// Create the $filter parameter for Edm target path. - /// - /// The OData context. - /// The string representation of the Edm target path. + /// + /// Create the $filter parameter for Edm target path. + /// + /// The OData context. + /// The string representation of the Edm target path. /// public static OpenApiParameter CreateFilter(this ODataContext context, string targetPath) { Utils.CheckArgumentNull(context, nameof(context)); - Utils.CheckArgumentNull(targetPath, nameof(targetPath)); - - IEdmTargetPath target = context.Model.GetTargetPath(targetPath); - if (target == null) + Utils.CheckArgumentNull(targetPath, nameof(targetPath)); + + IEdmTargetPath target = context.Model.GetTargetPath(targetPath); + if (target == null) return null; return context.CreateFilter(target); @@ -560,12 +560,12 @@ public static OpenApiParameter CreateFilter(this ODataContext context, string ta public static OpenApiParameter CreateOrderBy(this ODataContext context, string targetPath, IEdmEntityType entityType) { Utils.CheckArgumentNull(context, nameof(context)); - Utils.CheckArgumentNull(targetPath, nameof(targetPath)); - - IEdmTargetPath target = context.Model.GetTargetPath(targetPath); - if (target == null) - return null; - + Utils.CheckArgumentNull(targetPath, nameof(targetPath)); + + IEdmTargetPath target = context.Model.GetTargetPath(targetPath); + if (target == null) + return null; + return context.CreateOrderBy(target, entityType); } @@ -574,7 +574,7 @@ public static OpenApiParameter CreateOrderBy(this ODataContext context, IEdmEnti Utils.CheckArgumentNull(context, nameof(context)); Utils.CheckArgumentNull(entitySet, nameof(entitySet)); - return context.CreateOrderBy(entitySet, entitySet.EntityType()); + return context.CreateOrderBy(entitySet, entitySet.EntityType); } public static OpenApiParameter CreateOrderBy(this ODataContext context, IEdmSingleton singleton) @@ -582,7 +582,7 @@ public static OpenApiParameter CreateOrderBy(this ODataContext context, IEdmSing Utils.CheckArgumentNull(context, nameof(context)); Utils.CheckArgumentNull(singleton, nameof(singleton)); - return context.CreateOrderBy(singleton, singleton.EntityType()); + return context.CreateOrderBy(singleton, singleton.EntityType); } public static OpenApiParameter CreateOrderBy(this ODataContext context, IEdmNavigationProperty navigationProperty) @@ -603,15 +603,15 @@ public static OpenApiParameter CreateOrderBy(this ODataContext context, IEdmNavi public static OpenApiParameter CreateOrderBy(this ODataContext context, IEdmVocabularyAnnotatable target, IEdmEntityType entityType) {// patchwork to avoid breaking changes return context.CreateOrderBy(target, entityType as IEdmStructuredType); - } - - public static OpenApiParameter CreateOrderBy(this ODataContext context, string targetPath, IEdmStructuredType structuredType) - { - IEdmTargetPath target = context.Model.GetTargetPath(targetPath); - if (target == null) - return null; - - return context.CreateOrderBy(target, structuredType); + } + + public static OpenApiParameter CreateOrderBy(this ODataContext context, string targetPath, IEdmStructuredType structuredType) + { + IEdmTargetPath target = context.Model.GetTargetPath(targetPath); + if (target == null) + return null; + + return context.CreateOrderBy(target, structuredType); } public static OpenApiParameter CreateOrderBy(this ODataContext context, IEdmVocabularyAnnotatable target, IEdmStructuredType structuredType) @@ -677,12 +677,12 @@ public static OpenApiParameter CreateOrderBy(this ODataContext context, IEdmVoca public static OpenApiParameter CreateSelect(this ODataContext context, string targetPath, IEdmEntityType entityType) { Utils.CheckArgumentNull(context, nameof(context)); - Utils.CheckArgumentNull(targetPath, nameof(targetPath)); - - IEdmTargetPath target = context.Model.GetTargetPath(targetPath); - if (target == null) - return null; - + Utils.CheckArgumentNull(targetPath, nameof(targetPath)); + + IEdmTargetPath target = context.Model.GetTargetPath(targetPath); + if (target == null) + return null; + return context.CreateSelect(target, entityType); } @@ -691,7 +691,7 @@ public static OpenApiParameter CreateSelect(this ODataContext context, IEdmEntit Utils.CheckArgumentNull(context, nameof(context)); Utils.CheckArgumentNull(entitySet, nameof(entitySet)); - return context.CreateSelect(entitySet, entitySet.EntityType()); + return context.CreateSelect(entitySet, entitySet.EntityType); } public static OpenApiParameter CreateSelect(this ODataContext context, IEdmSingleton singleton) @@ -699,7 +699,7 @@ public static OpenApiParameter CreateSelect(this ODataContext context, IEdmSingl Utils.CheckArgumentNull(context, nameof(context)); Utils.CheckArgumentNull(singleton, nameof(singleton)); - return context.CreateSelect(singleton, singleton.EntityType()); + return context.CreateSelect(singleton, singleton.EntityType); } public static OpenApiParameter CreateSelect(this ODataContext context, IEdmNavigationProperty navigationProperty) @@ -722,13 +722,13 @@ public static OpenApiParameter CreateSelect(this ODataContext context, IEdmVocab return context.CreateSelect(target, entityType as IEdmStructuredType); } - public static OpenApiParameter CreateSelect(this ODataContext context, string targetPath, IEdmStructuredType structuredType) - { - IEdmTargetPath target = context.Model.GetTargetPath(targetPath); - if (target == null) - return null; - - return context.CreateSelect(target, structuredType); + public static OpenApiParameter CreateSelect(this ODataContext context, string targetPath, IEdmStructuredType structuredType) + { + IEdmTargetPath target = context.Model.GetTargetPath(targetPath); + if (target == null) + return null; + + return context.CreateSelect(target, structuredType); } public static OpenApiParameter CreateSelect(this ODataContext context, IEdmVocabularyAnnotatable target, IEdmStructuredType structuredType) @@ -783,12 +783,12 @@ public static OpenApiParameter CreateSelect(this ODataContext context, IEdmVocab public static OpenApiParameter CreateExpand(this ODataContext context, string targetPath, IEdmEntityType entityType) { Utils.CheckArgumentNull(context, nameof(context)); - Utils.CheckArgumentNull(targetPath, nameof(targetPath)); - - IEdmTargetPath target = context.Model.GetTargetPath(targetPath); - if (target == null) - return null; - + Utils.CheckArgumentNull(targetPath, nameof(targetPath)); + + IEdmTargetPath target = context.Model.GetTargetPath(targetPath); + if (target == null) + return null; + return context.CreateExpand(target, entityType); } @@ -797,7 +797,7 @@ public static OpenApiParameter CreateExpand(this ODataContext context, IEdmEntit Utils.CheckArgumentNull(context, nameof(context)); Utils.CheckArgumentNull(entitySet, nameof(entitySet)); - return context.CreateExpand(entitySet, entitySet.EntityType()); + return context.CreateExpand(entitySet, entitySet.EntityType); } public static OpenApiParameter CreateExpand(this ODataContext context, IEdmSingleton singleton) @@ -805,7 +805,7 @@ public static OpenApiParameter CreateExpand(this ODataContext context, IEdmSingl Utils.CheckArgumentNull(context, nameof(context)); Utils.CheckArgumentNull(singleton, nameof(singleton)); - return context.CreateExpand(singleton, singleton.EntityType()); + return context.CreateExpand(singleton, singleton.EntityType); } public static OpenApiParameter CreateExpand(this ODataContext context, IEdmNavigationProperty navigationProperty) @@ -828,13 +828,13 @@ public static OpenApiParameter CreateExpand(this ODataContext context, IEdmVocab return context.CreateExpand(target, entityType as IEdmStructuredType); } - public static OpenApiParameter CreateExpand(this ODataContext context, string targetPath, IEdmStructuredType structuredType) - { - IEdmTargetPath target = context.Model.GetTargetPath(targetPath); - if (target == null) - return null; - - return context.CreateExpand(target, structuredType); + public static OpenApiParameter CreateExpand(this ODataContext context, string targetPath, IEdmStructuredType structuredType) + { + IEdmTargetPath target = context.Model.GetTargetPath(targetPath); + if (target == null) + return null; + + return context.CreateExpand(target, structuredType); } public static OpenApiParameter CreateExpand(this ODataContext context, IEdmVocabularyAnnotatable target, IEdmStructuredType structuredType) diff --git a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs index bcbf6aea..5ea40c72 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs @@ -186,7 +186,7 @@ internal static IEnumerable GetAllCollectionEntityTypes(this var collectionEntityTypes = new HashSet( (context.EntityContainer? .EntitySets() - .Select(x => x.EntityType()) ?? + .Select(x => x.EntityType) ?? Enumerable.Empty()) .Union(context.Model .SchemaElements diff --git a/src/Microsoft.OpenApi.OData.Reader/Operation/DollarCountGetOperationHandler.cs b/src/Microsoft.OpenApi.OData.Reader/Operation/DollarCountGetOperationHandler.cs index 74082736..c9832820 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Operation/DollarCountGetOperationHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Operation/DollarCountGetOperationHandler.cs @@ -102,7 +102,7 @@ protected override void SetTags(OpenApiOperation operation) string TagNameFromNavigationSourceSegment(ODataNavigationSourceSegment sourceSegment) { - return $"{sourceSegment.NavigationSource.Name}.{sourceSegment.NavigationSource.EntityType().Name}"; + return $"{sourceSegment.NavigationSource.Name}.{sourceSegment.NavigationSource.EntityType.Name}"; } string TagNameFromNavigationPropertySegment() diff --git a/src/Microsoft.OpenApi.OData.Reader/Operation/EntityDeleteOperationHandler.cs b/src/Microsoft.OpenApi.OData.Reader/Operation/EntityDeleteOperationHandler.cs index b50b78f1..f34d8345 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Operation/EntityDeleteOperationHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Operation/EntityDeleteOperationHandler.cs @@ -38,7 +38,7 @@ protected override void Initialize(ODataContext context, ODataPath path) /// protected override void SetBasicInfo(OpenApiOperation operation) { - IEdmEntityType entityType = EntitySet.EntityType(); + IEdmEntityType entityType = EntitySet.EntityType; ODataKeySegment keySegment = Path.LastSegment as ODataKeySegment; // Description diff --git a/src/Microsoft.OpenApi.OData.Reader/Operation/EntityGetOperationHandler.cs b/src/Microsoft.OpenApi.OData.Reader/Operation/EntityGetOperationHandler.cs index 9a0cfd23..8a506cf8 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Operation/EntityGetOperationHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Operation/EntityGetOperationHandler.cs @@ -39,7 +39,7 @@ protected override void Initialize(ODataContext context, ODataPath path) /// protected override void SetBasicInfo(OpenApiOperation operation) { - IEdmEntityType entityType = EntitySet.EntityType(); + IEdmEntityType entityType = EntitySet.EntityType; ODataKeySegment keySegment = Path.LastSegment as ODataKeySegment; // Description @@ -93,12 +93,12 @@ protected override void SetResponses(OpenApiOperation operation) if (Context.Settings.EnableDerivedTypesReferencesForResponses) { - schema = EdmModelHelper.GetDerivedTypesReferenceSchema(EntitySet.EntityType(), Context.Model); + schema = EdmModelHelper.GetDerivedTypesReferenceSchema(EntitySet.EntityType, Context.Model); } if (Context.Settings.ShowLinks) { - links = Context.CreateLinks(entityType: EntitySet.EntityType(), entityName: EntitySet.Name, + links = Context.CreateLinks(entityType: EntitySet.EntityType, entityName: EntitySet.Name, entityKind: EntitySet.ContainerElementKind.ToString(), path: Path, parameters: PathParameters); } @@ -110,7 +110,7 @@ protected override void SetResponses(OpenApiOperation operation) Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = EntitySet.EntityType().FullName() + Id = EntitySet.EntityType.FullName() } }; } diff --git a/src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetGetOperationHandler.cs b/src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetGetOperationHandler.cs index de4f9d30..96b967d3 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetGetOperationHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetGetOperationHandler.cs @@ -48,7 +48,7 @@ protected override void SetBasicInfo(OpenApiOperation operation) // OperationId if (Context.Settings.EnableOperationId) { - string typeName = EntitySet.EntityType().Name; + string typeName = EntitySet.EntityType.Name; operation.OperationId = EntitySet.Name + "." + typeName + ".List" + Utils.UpperFirstChar(typeName); } } @@ -117,21 +117,21 @@ protected override void SetParameters(OpenApiOperation operation) // of just providing a comma-separated list of properties can be expressed via an array-valued // parameter with an enum constraint // $order - parameter = Context.CreateOrderBy(TargetPath, EntitySet.EntityType()) ?? Context.CreateOrderBy(EntitySet); + parameter = Context.CreateOrderBy(TargetPath, EntitySet.EntityType) ?? Context.CreateOrderBy(EntitySet); if (parameter != null) { operation.Parameters.Add(parameter); } // $select - parameter = Context.CreateSelect(TargetPath, EntitySet.EntityType()) ?? Context.CreateSelect(EntitySet); + parameter = Context.CreateSelect(TargetPath, EntitySet.EntityType) ?? Context.CreateSelect(EntitySet); if (parameter != null) { operation.Parameters.Add(parameter); } // $expand - parameter = Context.CreateExpand(TargetPath, EntitySet.EntityType()) ?? Context.CreateExpand(EntitySet); + parameter = Context.CreateExpand(TargetPath, EntitySet.EntityType) ?? Context.CreateExpand(EntitySet); if (parameter != null) { operation.Parameters.Add(parameter); @@ -151,7 +151,7 @@ protected override void SetResponses(OpenApiOperation operation) Reference = new OpenApiReference() { Type = ReferenceType.Response, - Id = $"{EntitySet.EntityType().FullName()}{Constants.CollectionSchemaSuffix}" + Id = $"{EntitySet.EntityType.FullName()}{Constants.CollectionSchemaSuffix}" }, } } diff --git a/src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetOperationHandler.cs b/src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetOperationHandler.cs index 898c83f8..58c3f66d 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetOperationHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetOperationHandler.cs @@ -38,7 +38,7 @@ protected override void SetTags(OpenApiOperation operation) { OpenApiTag tag = new OpenApiTag { - Name = EntitySet.Name + "." + EntitySet.EntityType().Name, + Name = EntitySet.Name + "." + EntitySet.EntityType.Name, }; tag.Extensions.Add(Constants.xMsTocType, new OpenApiString("page")); diff --git a/src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetPostOperationHandler.cs b/src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetPostOperationHandler.cs index aabe1057..4367beac 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetPostOperationHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetPostOperationHandler.cs @@ -31,9 +31,9 @@ protected override void Initialize(ODataContext context, ODataPath path) { base.Initialize(context, path); - _insertRestrictions = Context.Model.GetRecord(TargetPath, CapabilitiesConstants.InsertRestrictions); - var entityInsertRestrictions = Context.Model.GetRecord(EntitySet, CapabilitiesConstants.InsertRestrictions); - _insertRestrictions?.MergePropertiesIfNull(entityInsertRestrictions); + _insertRestrictions = Context.Model.GetRecord(TargetPath, CapabilitiesConstants.InsertRestrictions); + var entityInsertRestrictions = Context.Model.GetRecord(EntitySet, CapabilitiesConstants.InsertRestrictions); + _insertRestrictions?.MergePropertiesIfNull(entityInsertRestrictions); _insertRestrictions ??= entityInsertRestrictions; } @@ -48,7 +48,7 @@ protected override void SetBasicInfo(OpenApiOperation operation) // OperationId if (Context.Settings.EnableOperationId) { - string typeName = EntitySet.EntityType().Name; + string typeName = EntitySet.EntityType.Name; operation.OperationId = EntitySet.Name + "." + typeName + ".Create" + Utils.UpperFirstChar(typeName); } } @@ -125,9 +125,9 @@ private IDictionary GetContentDescription() OpenApiSchema schema = GetEntitySchema(); var content = new Dictionary(); - if (EntitySet.EntityType().HasStream) + if (EntitySet.EntityType.HasStream) { - IEnumerable mediaTypes = Context.Model.GetCollection(EntitySet.EntityType(), + IEnumerable mediaTypes = Context.Model.GetCollection(EntitySet.EntityType, CoreConstants.AcceptableMediaTypes); if (mediaTypes != null) @@ -150,28 +150,28 @@ private IDictionary GetContentDescription() }); } } - else - { - // Add the annotated request content media types - IEnumerable mediaTypes = _insertRestrictions?.RequestContentTypes; - if (mediaTypes != null) - { - foreach (string mediaType in mediaTypes) - { - content.Add(mediaType, new OpenApiMediaType - { - Schema = schema - }); - } - } - else - { - // Default content type - content.Add(Constants.ApplicationJsonMediaType, new OpenApiMediaType - { - Schema = schema - }); - } + else + { + // Add the annotated request content media types + IEnumerable mediaTypes = _insertRestrictions?.RequestContentTypes; + if (mediaTypes != null) + { + foreach (string mediaType in mediaTypes) + { + content.Add(mediaType, new OpenApiMediaType + { + Schema = schema + }); + } + } + else + { + // Default content type + content.Add(Constants.ApplicationJsonMediaType, new OpenApiMediaType + { + Schema = schema + }); + } } return content; @@ -187,7 +187,7 @@ private OpenApiSchema GetEntitySchema() if (Context.Settings.EnableDerivedTypesReferencesForRequestBody) { - schema = EdmModelHelper.GetDerivedTypesReferenceSchema(EntitySet.EntityType(), Context.Model); + schema = EdmModelHelper.GetDerivedTypesReferenceSchema(EntitySet.EntityType, Context.Model); } if (schema == null) @@ -198,7 +198,7 @@ private OpenApiSchema GetEntitySchema() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = EntitySet.EntityType().FullName() + Id = EntitySet.EntityType.FullName() } }; } diff --git a/src/Microsoft.OpenApi.OData.Reader/Operation/EntityUpdateOperationHandler.cs b/src/Microsoft.OpenApi.OData.Reader/Operation/EntityUpdateOperationHandler.cs index 7ce526df..eb317b3f 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Operation/EntityUpdateOperationHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Operation/EntityUpdateOperationHandler.cs @@ -25,16 +25,16 @@ protected override void Initialize(ODataContext context, ODataPath path) { base.Initialize(context, path); - _updateRestrictions = Context.Model.GetRecord(TargetPath, CapabilitiesConstants.UpdateRestrictions); - var entityUpdateRestrictions = Context.Model.GetRecord(EntitySet, CapabilitiesConstants.UpdateRestrictions); - _updateRestrictions?.MergePropertiesIfNull(entityUpdateRestrictions); + _updateRestrictions = Context.Model.GetRecord(TargetPath, CapabilitiesConstants.UpdateRestrictions); + var entityUpdateRestrictions = Context.Model.GetRecord(EntitySet, CapabilitiesConstants.UpdateRestrictions); + _updateRestrictions?.MergePropertiesIfNull(entityUpdateRestrictions); _updateRestrictions ??= entityUpdateRestrictions; } /// protected override void SetBasicInfo(OpenApiOperation operation) { - IEdmEntityType entityType = EntitySet.EntityType(); + IEdmEntityType entityType = EntitySet.EntityType; ODataKeySegment keySegment = Path.LastSegment as ODataKeySegment; // Summary and Description @@ -100,8 +100,8 @@ protected IDictionary GetContent() }; return content; - } - + } + /// protected override void SetResponses(OpenApiOperation operation) { @@ -141,7 +141,7 @@ private OpenApiSchema GetOpenApiSchema() { if (Context.Settings.EnableDerivedTypesReferencesForRequestBody) { - return EdmModelHelper.GetDerivedTypesReferenceSchema(EntitySet.EntityType(), Context.Model); + return EdmModelHelper.GetDerivedTypesReferenceSchema(EntitySet.EntityType, Context.Model); } return new OpenApiSchema @@ -150,7 +150,7 @@ private OpenApiSchema GetOpenApiSchema() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = EntitySet.EntityType().FullName() + Id = EntitySet.EntityType.FullName() } }; } diff --git a/src/Microsoft.OpenApi.OData.Reader/Operation/ODataTypeCastGetOperationHandler.cs b/src/Microsoft.OpenApi.OData.Reader/Operation/ODataTypeCastGetOperationHandler.cs index 604f31d3..84574f72 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Operation/ODataTypeCastGetOperationHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Operation/ODataTypeCastGetOperationHandler.cs @@ -246,8 +246,8 @@ protected override void SetTags(OpenApiOperation operation) var singleton = navigationSource as IEdmSingleton; tagName = entitySet != null - ? entitySet.Name + "." + entitySet.EntityType().Name - : singleton.Name + "." + singleton.EntityType().Name; + ? entitySet.Name + "." + entitySet.EntityType.Name + : singleton.Name + "." + singleton.EntityType.Name; } else if (SecondLastSegment is ODataComplexPropertySegment) { @@ -306,8 +306,8 @@ protected override void SetParameters(OpenApiOperation operation) if(IsSingleElement) { new OpenApiParameter[] { - Context.CreateSelect(TargetPath, entitySet.EntityType()) ?? Context.CreateSelect(entitySet), - Context.CreateExpand(TargetPath, entitySet.EntityType()) ?? Context.CreateExpand(entitySet), + Context.CreateSelect(TargetPath, entitySet.EntityType) ?? Context.CreateSelect(entitySet), + Context.CreateExpand(TargetPath, entitySet.EntityType) ?? Context.CreateExpand(entitySet), } .Where(x => x != null) .ToList() @@ -318,9 +318,9 @@ protected override void SetParameters(OpenApiOperation operation) GetParametersForAnnotableOfMany(entitySet) .Union( new OpenApiParameter[] { - Context.CreateOrderBy(TargetPath, entitySet.EntityType()) ?? Context.CreateOrderBy(entitySet), - Context.CreateSelect(TargetPath, entitySet.EntityType()) ?? Context.CreateSelect(entitySet), - Context.CreateExpand(TargetPath, entitySet.EntityType()) ?? Context.CreateExpand(entitySet), + Context.CreateOrderBy(TargetPath, entitySet.EntityType) ?? Context.CreateOrderBy(entitySet), + Context.CreateSelect(TargetPath, entitySet.EntityType) ?? Context.CreateSelect(entitySet), + Context.CreateExpand(TargetPath, entitySet.EntityType) ?? Context.CreateExpand(entitySet), }) .Where(x => x != null) .ToList() @@ -330,8 +330,8 @@ protected override void SetParameters(OpenApiOperation operation) else if(singleton != null) { new OpenApiParameter[] { - Context.CreateSelect(TargetPath, singleton.EntityType()) ?? Context.CreateSelect(singleton), - Context.CreateExpand(TargetPath, singleton.EntityType()) ?? Context.CreateExpand(singleton), + Context.CreateSelect(TargetPath, singleton.EntityType) ?? Context.CreateSelect(singleton), + Context.CreateExpand(TargetPath, singleton.EntityType) ?? Context.CreateExpand(singleton), } .Where(x => x != null) .ToList() diff --git a/src/Microsoft.OpenApi.OData.Reader/Operation/SingletonGetOperationHandler.cs b/src/Microsoft.OpenApi.OData.Reader/Operation/SingletonGetOperationHandler.cs index 0dc90b9e..758c94ee 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Operation/SingletonGetOperationHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Operation/SingletonGetOperationHandler.cs @@ -47,7 +47,7 @@ protected override void SetBasicInfo(OpenApiOperation operation) // OperationId, it should be unique among all operations described in the API. if (Context.Settings.EnableOperationId) { - string typeName = Singleton.EntityType().Name; + string typeName = Singleton.EntityType.Name; operation.OperationId = Singleton.Name + "." + typeName + ".Get" + Utils.UpperFirstChar(typeName); } } @@ -80,12 +80,12 @@ protected override void SetResponses(OpenApiOperation operation) if (Context.Settings.EnableDerivedTypesReferencesForResponses) { - schema = EdmModelHelper.GetDerivedTypesReferenceSchema(Singleton.EntityType(), Context.Model); + schema = EdmModelHelper.GetDerivedTypesReferenceSchema(Singleton.EntityType, Context.Model); } if (Context.Settings.ShowLinks) { - links = Context.CreateLinks(entityType: Singleton.EntityType(), entityName: Singleton.Name, + links = Context.CreateLinks(entityType: Singleton.EntityType, entityName: Singleton.Name, entityKind: Singleton.ContainerElementKind.ToString(), path: Path, parameters: PathParameters); } @@ -97,7 +97,7 @@ protected override void SetResponses(OpenApiOperation operation) Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = Singleton.EntityType().FullName() + Id = Singleton.EntityType.FullName() } }; } diff --git a/src/Microsoft.OpenApi.OData.Reader/Operation/SingletonOperationHandler.cs b/src/Microsoft.OpenApi.OData.Reader/Operation/SingletonOperationHandler.cs index 39760948..638f05d1 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Operation/SingletonOperationHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Operation/SingletonOperationHandler.cs @@ -40,7 +40,7 @@ protected override void SetTags(OpenApiOperation operation) // For example: "Me.User" OpenApiTag tag = new OpenApiTag { - Name = Singleton.Name + "." + Singleton.EntityType().Name, + Name = Singleton.Name + "." + Singleton.EntityType.Name, }; // Use an extension for TOC (Table of Content) diff --git a/src/Microsoft.OpenApi.OData.Reader/Operation/SingletonPatchOperationHandler.cs b/src/Microsoft.OpenApi.OData.Reader/Operation/SingletonPatchOperationHandler.cs index 68e3c11a..03c0b47b 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Operation/SingletonPatchOperationHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Operation/SingletonPatchOperationHandler.cs @@ -47,7 +47,7 @@ protected override void SetBasicInfo(OpenApiOperation operation) // OperationId if (Context.Settings.EnableOperationId) { - string typeName = Singleton.EntityType().Name; + string typeName = Singleton.EntityType.Name; operation.OperationId = Singleton.Name + "." + typeName + ".Update" + Utils.UpperFirstChar(typeName); } } @@ -114,7 +114,7 @@ private OpenApiSchema GetOpenApiSchema() { if (Context.Settings.EnableDerivedTypesReferencesForRequestBody) { - return EdmModelHelper.GetDerivedTypesReferenceSchema(Singleton.EntityType(), Context.Model); + return EdmModelHelper.GetDerivedTypesReferenceSchema(Singleton.EntityType, Context.Model); } return new OpenApiSchema @@ -123,7 +123,7 @@ private OpenApiSchema GetOpenApiSchema() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = Singleton.EntityType().FullName() + Id = Singleton.EntityType.FullName() } }; } diff --git a/src/Microsoft.OpenApi.OData.Reader/PathItem/EntityPathItemHandler.cs b/src/Microsoft.OpenApi.OData.Reader/PathItem/EntityPathItemHandler.cs index 7c66d7d9..243d6f3b 100644 --- a/src/Microsoft.OpenApi.OData.Reader/PathItem/EntityPathItemHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/PathItem/EntityPathItemHandler.cs @@ -64,7 +64,7 @@ protected override void SetOperations(OpenApiPathItem item) protected override void SetExtensions(OpenApiPathItem pathItem) { base.SetExtensions(pathItem); - pathItem.Extensions.AddCustomAttributesToExtensions(Context, EntitySet.EntityType()); + pathItem.Extensions.AddCustomAttributesToExtensions(Context, EntitySet.EntityType); } } } diff --git a/src/Microsoft.OpenApi.OData.Reader/PathItem/EntitySetPathItemHandler.cs b/src/Microsoft.OpenApi.OData.Reader/PathItem/EntitySetPathItemHandler.cs index a6c0019b..a6f8cb70 100644 --- a/src/Microsoft.OpenApi.OData.Reader/PathItem/EntitySetPathItemHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/PathItem/EntitySetPathItemHandler.cs @@ -59,7 +59,7 @@ protected override void Initialize(ODataContext context, ODataPath path) protected override void SetBasicInfo(OpenApiPathItem pathItem) { base.SetBasicInfo(pathItem); - pathItem.Description = $"Provides operations to manage the collection of {EntitySet.EntityType().Name} entities."; + pathItem.Description = $"Provides operations to manage the collection of {EntitySet.EntityType.Name} entities."; } /// diff --git a/src/Microsoft.OpenApi.OData.Reader/PathItem/MediaEntityPathItemHandler.cs b/src/Microsoft.OpenApi.OData.Reader/PathItem/MediaEntityPathItemHandler.cs index 83eeae03..17dd2d7f 100644 --- a/src/Microsoft.OpenApi.OData.Reader/PathItem/MediaEntityPathItemHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/PathItem/MediaEntityPathItemHandler.cs @@ -82,7 +82,7 @@ protected override void Initialize(ODataContext context, ODataPath path) protected override void SetBasicInfo(OpenApiPathItem pathItem) { base.SetBasicInfo(pathItem); - pathItem.Description = $"Provides operations to manage the media for the {(EntitySet?.EntityType() ?? Singleton?.EntityType()).Name} entity."; + pathItem.Description = $"Provides operations to manage the media for the {(EntitySet?.EntityType ?? Singleton?.EntityType).Name} entity."; } } } diff --git a/src/Microsoft.OpenApi.OData.Reader/PathItem/RefPathItemHandler.cs b/src/Microsoft.OpenApi.OData.Reader/PathItem/RefPathItemHandler.cs index f4f28342..c5d59673 100644 --- a/src/Microsoft.OpenApi.OData.Reader/PathItem/RefPathItemHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/PathItem/RefPathItemHandler.cs @@ -149,7 +149,7 @@ protected override void Initialize(ODataContext context, ODataPath path) protected override void SetBasicInfo(OpenApiPathItem pathItem) { base.SetBasicInfo(pathItem); - pathItem.Description = $"Provides operations to manage the collection of {NavigationSource?.EntityType().Name ?? NavigationProperty?.Type.ShortQualifiedName()} entities."; + pathItem.Description = $"Provides operations to manage the collection of {NavigationSource?.EntityType.Name ?? NavigationProperty?.Type.ShortQualifiedName()} entities."; } } } diff --git a/src/Microsoft.OpenApi.OData.Reader/PathItem/SingletonPathItemHandler.cs b/src/Microsoft.OpenApi.OData.Reader/PathItem/SingletonPathItemHandler.cs index 9cb2cb48..7e38a391 100644 --- a/src/Microsoft.OpenApi.OData.Reader/PathItem/SingletonPathItemHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/PathItem/SingletonPathItemHandler.cs @@ -61,7 +61,7 @@ protected override void Initialize(ODataContext context, ODataPath path) protected override void SetBasicInfo(OpenApiPathItem pathItem) { base.SetBasicInfo(pathItem); - pathItem.Description = $"Provides operations to manage the {Singleton.EntityType().Name} singleton."; + pathItem.Description = $"Provides operations to manage the {Singleton.EntityType.Name} singleton."; } /// From b5a7c3766b021bde4b04f80f536a8ca65df1c379 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 15 Aug 2024 09:37:26 -0400 Subject: [PATCH 07/10] chore: bumps major version Signed-off-by: Vincent Biret --- .../Microsoft.OpenAPI.OData.Reader.csproj | 5 +++-- 1 file changed, 3 insertions(+), 2 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 cc3ee1b8..5c29e7d2 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj +++ b/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj @@ -15,13 +15,14 @@ net8 Microsoft.OpenApi.OData true - 1.6.8 + 2.0.0 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 - - Adds support for configuring composable functions generations #551 + - Upgraded to Microsoft.Odata.Edm 8.0.0 + - Cleaned up obsolete APIs Microsoft.OpenApi.OData.Reader ..\..\tool\Microsoft.OpenApi.OData.snk From 9eb024ca0b93da070a2350f6aac172701d065ee4 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 15 Aug 2024 09:39:40 -0400 Subject: [PATCH 08/10] chore: adds platform attributes to suppress warnings --- src/OoasGui/MainForm.cs | 1 + src/OoasGui/Program.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/OoasGui/MainForm.cs b/src/OoasGui/MainForm.cs index 6afe627f..6b0c1ac0 100644 --- a/src/OoasGui/MainForm.cs +++ b/src/OoasGui/MainForm.cs @@ -22,6 +22,7 @@ namespace OoasGui { + [System.Runtime.Versioning.SupportedOSPlatform("windows")] public partial class MainForm : Form { private OpenApiFormat Format { get; set; } = OpenApiFormat.Json; diff --git a/src/OoasGui/Program.cs b/src/OoasGui/Program.cs index 7ab918e7..2384e450 100644 --- a/src/OoasGui/Program.cs +++ b/src/OoasGui/Program.cs @@ -3,6 +3,7 @@ namespace OoasGui { + [System.Runtime.Versioning.SupportedOSPlatform("windows")] static class Program { /// From 3f440c7210f65a459016367946cd33b88ea83b76 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 15 Aug 2024 10:31:26 -0400 Subject: [PATCH 09/10] fix: net8.0 moniker --- .../Microsoft.OpenAPI.OData.Reader.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 5c29e7d2..dd62e5e5 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj +++ b/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj @@ -12,7 +12,7 @@ Microsoft Microsoft Open API OData Reader Microsoft.OpenApi.OData - net8 + net8.0 Microsoft.OpenApi.OData true 2.0.0 @@ -23,6 +23,7 @@ - Upgraded to Microsoft.Odata.Edm 8.0.0 - Cleaned up obsolete APIs + - Changed target framework to net8.0 Microsoft.OpenApi.OData.Reader ..\..\tool\Microsoft.OpenApi.OData.snk From 107de46474cf420fa8e6d5fb8dc8081640a8c6f9 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 15 Aug 2024 10:33:00 -0400 Subject: [PATCH 10/10] chore: switches to a preview version Signed-off-by: Vincent Biret --- .../Microsoft.OpenAPI.OData.Reader.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 dd62e5e5..4283a792 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj +++ b/src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj @@ -15,7 +15,7 @@ net8.0 Microsoft.OpenApi.OData true - 2.0.0 + 2.0.0-preview.1 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