Skip to content

Commit

Permalink
Finds all the derived types for a schema element (#321)
Browse files Browse the repository at this point in the history
* Find all derived types for a schema element

* Update release notes
  • Loading branch information
irvinesunday authored Dec 19, 2022
1 parent f56384c commit 22ebf50
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal static OpenApiSchema GetDerivedTypesReferenceSchema(IEdmStructuredType
Utils.CheckArgumentNull(edmModel, nameof(edmModel));
if(structuredType is not IEdmSchemaElement schemaElement) throw new ArgumentException("The type is not a schema element.", nameof(structuredType));

IEnumerable<IEdmSchemaElement> derivedTypes = edmModel.FindDirectlyDerivedTypes(structuredType).OfType<IEdmSchemaElement>();
IEnumerable<IEdmSchemaElement> derivedTypes = edmModel.FindAllDerivedTypes(structuredType).OfType<IEdmSchemaElement>();

if (!derivedTypes.Any())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<PackageId>Microsoft.OpenApi.OData</PackageId>
<SignAssembly>true</SignAssembly>
<Version>1.2.0-preview9</Version>
<Version>1.2.0-preview10</Version>
<Description>This package contains the codes you need to convert OData CSDL to Open API Document of Model.</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>Microsoft OpenApi OData EDM</PackageTags>
Expand All @@ -31,6 +31,7 @@
- Adds custom parameters to $count and ODataTypeCast paths' Get operations #207
- Adds support for configuring the default value of derived types' @odata.type property #304
- Adds OData query parameters to $count endpoints #313
- Finds all the derived types for a schema element #84
</PackageReleaseNotes>
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
<AssemblyOriginatorKeyFile>..\..\tool\Microsoft.OpenApi.OData.snk</AssemblyOriginatorKeyFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ public void GetDerivedTypesReferenceSchemaReturnsDerivedTypesReferencesInSchemaI

// Act
schema = Common.EdmModelHelper.GetDerivedTypesReferenceSchema(entityType, edmModel);
int derivedTypesCount = edmModel.FindDirectlyDerivedTypes(entityType).OfType<IEdmEntityType>().Count() + 1; // + 1 the base type
int derivedTypesCount = edmModel.FindAllDerivedTypes(entityType).OfType<IEdmEntityType>().Count() + 1; // + 1 the base type

// Assert
Assert.NotNull(schema.OneOf);
Expand Down

0 comments on commit 22ebf50

Please sign in to comment.