diff --git a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs index 1bad9d90..1246cfd9 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Edm/ODataPathProvider.cs @@ -293,7 +293,7 @@ private bool ShouldCreateComplexPropertyPaths(IEdmStructuralProperty complexProp Debug.Assert(complexProperty != null); Debug.Assert(convertSettings != null); - if (!convertSettings.UseRestrictionAnnotationsToGeneratePathsForComplexProperties) + if (!convertSettings.RequireRestrictionAnnotationsToGenerateComplexPropertyPaths) return true; bool isReadable = _model.GetRecord(complexProperty, CapabilitiesConstants.ReadRestrictions)?.Readable ?? false; diff --git a/src/Microsoft.OpenApi.OData.Reader/OpenApiConvertSettings.cs b/src/Microsoft.OpenApi.OData.Reader/OpenApiConvertSettings.cs index 548f35c8..eeba4fa8 100644 --- a/src/Microsoft.OpenApi.OData.Reader/OpenApiConvertSettings.cs +++ b/src/Microsoft.OpenApi.OData.Reader/OpenApiConvertSettings.cs @@ -228,7 +228,7 @@ public string PathPrefix /// /// Gets/Sets a value indicating whether or not to use restrictions annotations to generate paths for complex properties. /// - public bool UseRestrictionAnnotationsToGeneratePathsForComplexProperties { get; set; } = true; + public bool RequireRestrictionAnnotationsToGenerateComplexPropertyPaths { get; set; } = true; internal OpenApiConvertSettings Clone() { @@ -268,7 +268,7 @@ internal OpenApiConvertSettings Clone() AddEnumDescriptionExtension = this.AddEnumDescriptionExtension, ErrorResponsesAsDefault = this.ErrorResponsesAsDefault, InnerErrorComplexTypeName = this.InnerErrorComplexTypeName, - UseRestrictionAnnotationsToGeneratePathsForComplexProperties = this.UseRestrictionAnnotationsToGeneratePathsForComplexProperties + RequireRestrictionAnnotationsToGenerateComplexPropertyPaths = this.RequireRestrictionAnnotationsToGenerateComplexPropertyPaths }; return newSettings; diff --git a/src/Microsoft.OpenApi.OData.Reader/PathItem/ComplexPropertyItemHandler.cs b/src/Microsoft.OpenApi.OData.Reader/PathItem/ComplexPropertyItemHandler.cs index 74d218d3..4d1a1459 100644 --- a/src/Microsoft.OpenApi.OData.Reader/PathItem/ComplexPropertyItemHandler.cs +++ b/src/Microsoft.OpenApi.OData.Reader/PathItem/ComplexPropertyItemHandler.cs @@ -24,16 +24,16 @@ internal class ComplexPropertyItemHandler : PathItemHandler protected override void SetOperations(OpenApiPathItem item) { bool isReadable = Context.Model.GetRecord(ComplexProperty, CapabilitiesConstants.ReadRestrictions)?.Readable ?? false; - if ((Context.Settings.UseRestrictionAnnotationsToGeneratePathsForComplexProperties && isReadable) || - !Context.Settings.UseRestrictionAnnotationsToGeneratePathsForComplexProperties) + if ((Context.Settings.RequireRestrictionAnnotationsToGenerateComplexPropertyPaths && isReadable) || + !Context.Settings.RequireRestrictionAnnotationsToGenerateComplexPropertyPaths) { AddOperation(item, OperationType.Get); } UpdateRestrictionsType update = Context.Model.GetRecord(ComplexProperty, CapabilitiesConstants.UpdateRestrictions); bool isUpdatable = update?.Updatable ?? false; - if ((Context.Settings.UseRestrictionAnnotationsToGeneratePathsForComplexProperties && isUpdatable) || - !Context.Settings.UseRestrictionAnnotationsToGeneratePathsForComplexProperties) + if ((Context.Settings.RequireRestrictionAnnotationsToGenerateComplexPropertyPaths && isUpdatable) || + !Context.Settings.RequireRestrictionAnnotationsToGenerateComplexPropertyPaths) { if (update != null && update.IsUpdateMethodPut) { @@ -48,8 +48,8 @@ protected override void SetOperations(OpenApiPathItem item) if (Path.LastSegment is ODataComplexPropertySegment segment && segment.Property.Type.IsCollection()) { bool isInsertable = Context.Model.GetRecord(ComplexProperty, CapabilitiesConstants.InsertRestrictions)?.Insertable ?? false; - if ((Context.Settings.UseRestrictionAnnotationsToGeneratePathsForComplexProperties && isInsertable) || - !Context.Settings.UseRestrictionAnnotationsToGeneratePathsForComplexProperties) + if ((Context.Settings.RequireRestrictionAnnotationsToGenerateComplexPropertyPaths && isInsertable) || + !Context.Settings.RequireRestrictionAnnotationsToGenerateComplexPropertyPaths) { AddOperation(item, OperationType.Post); } diff --git a/src/Microsoft.OpenApi.OData.Reader/PublicAPI.Unshipped.txt b/src/Microsoft.OpenApi.OData.Reader/PublicAPI.Unshipped.txt index 5a2f8601..f2e675b7 100644 --- a/src/Microsoft.OpenApi.OData.Reader/PublicAPI.Unshipped.txt +++ b/src/Microsoft.OpenApi.OData.Reader/PublicAPI.Unshipped.txt @@ -5,8 +5,8 @@ abstract Microsoft.OpenApi.OData.Edm.ODataSegment.GetAnnotables() -> System.Coll Microsoft.OpenApi.OData.Common.Utils Microsoft.OpenApi.OData.Edm.EdmModelExtensions Microsoft.OpenApi.OData.Edm.EdmTypeExtensions -Microsoft.OpenApi.OData.OpenApiConvertSettings.UseRestrictionAnnotationsToGeneratePathsForComplexProperties.get -> bool -Microsoft.OpenApi.OData.OpenApiConvertSettings.UseRestrictionAnnotationsToGeneratePathsForComplexProperties.set -> void +Microsoft.OpenApi.OData.OpenApiConvertSettings.RequireRestrictionAnnotationsToGenerateComplexPropertyPaths.get -> bool +Microsoft.OpenApi.OData.OpenApiConvertSettings.RequireRestrictionAnnotationsToGenerateComplexPropertyPaths.set -> void static Microsoft.OpenApi.OData.Edm.EdmTypeExtensions.ShouldPathParameterBeQuoted(this Microsoft.OData.Edm.IEdmType edmType, Microsoft.OpenApi.OData.OpenApiConvertSettings settings) -> bool Microsoft.OpenApi.OData.Edm.IODataPathProvider Microsoft.OpenApi.OData.Edm.IODataPathProvider.CanFilter(Microsoft.OData.Edm.IEdmElement element) -> bool diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiPathItemGeneratorTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiPathItemGeneratorTests.cs index 804a26c3..e79bd46e 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiPathItemGeneratorTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiPathItemGeneratorTests.cs @@ -51,7 +51,7 @@ public void CreatePathItemsReturnsForBasicModel(bool useAnnotationToGeneratePath OpenApiConvertSettings settings = new OpenApiConvertSettings { EnableKeyAsSegment = true, - UseRestrictionAnnotationsToGeneratePathsForComplexProperties = useAnnotationToGeneratePath + RequireRestrictionAnnotationsToGenerateComplexPropertyPaths = useAnnotationToGeneratePath }; ODataContext context = new ODataContext(model, settings); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiPathsGeneratorTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiPathsGeneratorTests.cs index 334ebcd8..d643dc08 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiPathsGeneratorTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiPathsGeneratorTests.cs @@ -50,7 +50,7 @@ public void CreatePathsReturnsForBasicModel(bool useAnnotationToGeneratePath, in OpenApiConvertSettings settings = new OpenApiConvertSettings { EnableKeyAsSegment = true, - UseRestrictionAnnotationsToGeneratePathsForComplexProperties = useAnnotationToGeneratePath + RequireRestrictionAnnotationsToGenerateComplexPropertyPaths = useAnnotationToGeneratePath }; ODataContext context = new ODataContext(model, settings); @@ -110,7 +110,7 @@ public void CreatePathsReturnsForBasicModelWithPrefix(bool useAnnotationToGenera { EnableKeyAsSegment = true, PathPrefix = "some/prefix", - UseRestrictionAnnotationsToGeneratePathsForComplexProperties = useAnnotationToGeneratePath + RequireRestrictionAnnotationsToGenerateComplexPropertyPaths = useAnnotationToGeneratePath }; ODataContext context = new ODataContext(model, settings); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/ComplexPropertyPathItemHandlerTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/ComplexPropertyPathItemHandlerTests.cs index b8cfd35c..ba471d98 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/ComplexPropertyPathItemHandlerTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/PathItem/ComplexPropertyPathItemHandlerTests.cs @@ -46,7 +46,7 @@ public void SetsDefaultOperations(bool useAnnotationToGeneratePath, bool annotat var model = EntitySetPathItemHandlerTests.GetEdmModel(annotation: annotation, target: target); var convertSettings = new OpenApiConvertSettings { - UseRestrictionAnnotationsToGeneratePathsForComplexProperties = useAnnotationToGeneratePath + RequireRestrictionAnnotationsToGenerateComplexPropertyPaths = useAnnotationToGeneratePath }; var context = new ODataContext(model, convertSettings); var entitySet = model.EntityContainer.FindEntitySet("Customers"); @@ -99,7 +99,7 @@ public void SetsUpdateOperationWithUpdateMethodUpdateRestrictions(bool useAnnota var model = EntitySetPathItemHandlerTests.GetEdmModel(annotation: annotation, target: target); var convertSettings = new OpenApiConvertSettings { - UseRestrictionAnnotationsToGeneratePathsForComplexProperties = useAnnotationToGeneratePath + RequireRestrictionAnnotationsToGenerateComplexPropertyPaths = useAnnotationToGeneratePath }; var context = new ODataContext(model, convertSettings); var entitySet = model.EntityContainer.FindEntitySet("Customers"); @@ -157,7 +157,7 @@ public void SetsPostOnCollectionProperties(bool useAnnotationToGeneratePath, boo var model = EntitySetPathItemHandlerTests.GetEdmModel(annotation: annotation, target: target); var convertSettings = new OpenApiConvertSettings { - UseRestrictionAnnotationsToGeneratePathsForComplexProperties = useAnnotationToGeneratePath + RequireRestrictionAnnotationsToGenerateComplexPropertyPaths = useAnnotationToGeneratePath }; var context = new ODataContext(model, convertSettings); var entitySet = model.EntityContainer.FindEntitySet("Customers");