Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@
<PackageTags>Microsoft OpenApi OData EDM</PackageTags>
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET.OData</RepositoryUrl>
<PackageReleaseNotes>
- Further fix for generating unique operation ids for navigation property paths with composable overloaded functions #596
</PackageReleaseNotes>
- Upgraded to Microsoft.Odata.Edm 8.0.0
- Cleaned up obsolete APIs
- Changed target framework to net8.0
- Adds support for retrieving collection of enum values from UpdateMethod property of UpdateRestrictions annotation #564
- Adds nullable to double schema conversions #581
- Updates tag names for actions/functions operations #585
</PackageReleaseNotes>
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
<AssemblyOriginatorKeyFile>..\..\tool\Microsoft.OpenApi.OData.snk</AssemblyOriginatorKeyFile>
<OutputPath Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">..\..\bin\Debug\</OutputPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}

/// <inheritdoc/>
protected override void SetBasicInfo(OpenApiOperation operation)

Check warning on line 67 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 25 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)

Check warning on line 67 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 25 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)
{
// Summary
operation.Summary = "Invoke " + (EdmOperation.IsAction() ? "action " : "function ") + EdmOperation.Name;
Expand All @@ -81,7 +81,6 @@
// duplicates in entity vs entityset functions/actions

List<string> identifiers = new();
string pathHash = string.Empty;
foreach (ODataSegment segment in Path.Segments)
{
if (segment is ODataKeySegment keySegment)
Expand All @@ -93,7 +92,7 @@
}

// We'll consider alternate keys in the operation id to eliminate potential duplicates with operation id of primary path
if (segment == Path.Segments.Last())

Check warning on line 95 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Indexing at Count-1 should be used instead of the "Enumerable" extension method "Last" (https://rules.sonarsource.com/csharp/RSPEC-6608)

Check warning on line 95 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Indexing at Count-1 should be used instead of the "Enumerable" extension method "Last" (https://rules.sonarsource.com/csharp/RSPEC-6608)
{
identifiers.Add("By" + string.Join("", keySegment.Identifier.Split(',').Select(static x => Utils.UpperFirstChar(x))));
}
Expand All @@ -102,18 +101,6 @@
identifiers.Add(keySegment.Identifier);
}
}
else if (segment is ODataOperationSegment opSegment)
{
if (opSegment.Operation is IEdmFunction function && Context.Model.IsOperationOverload(function))
{
// Hash the segment to avoid duplicate operationIds
pathHash = string.IsNullOrEmpty(pathHash)
? opSegment.GetPathHash(Context.Settings)
: (pathHash + opSegment.GetPathHash(Context.Settings)).GetHashSHA256().Substring(0, 4);
}

identifiers.Add(segment.Identifier);
}
else
{
identifiers.Add(segment.Identifier);
Expand All @@ -122,13 +109,21 @@

string operationId = string.Join(".", identifiers);

if (!string.IsNullOrEmpty(pathHash))
if (EdmOperation.IsAction())
{
operation.OperationId = operationId + "-" + pathHash;
operation.OperationId = operationId;
}
else
{
operation.OperationId = operationId;
if (Path.LastSegment is ODataOperationSegment operationSegment &&
Context.Model.IsOperationOverload(operationSegment.Operation))
{
operation.OperationId = operationId + "-" + Path.LastSegment.GetPathHash(Context.Settings);
}
else
{
operation.OperationId = operationId;
}
}
}

Expand All @@ -152,7 +147,7 @@
}

/// <summary>
/// Genrates the tag name for the operation.
/// Genrates the tag name for the operation. Adds Action or Function name to the tag name if the operation is an action or function.
/// </summary>
/// <param name="tagName">The generated tag name.</param>
/// <param name="skip">The number of segments to skip.</param>
Expand All @@ -165,16 +160,27 @@
case ODataNavigationPropertySegment:
tagName = EdmModelHelper.GenerateNavigationPropertyPathTagName(Path, Context);
break;
case ODataOperationSegment:
case ODataOperationImportSegment:
// Previous segmment could be a navigation property or a navigation source segment
case ODataKeySegment:
skip += 1;
GenerateTagName(out tagName, skip);
break;
// ODataNavigationSourceSegment
// If the operation is a function or action, append the word "Function" or "Action" to the tag name
case ODataOperationSegment operationSegment:
tagName = NavigationSource.Name + "." + NavigationSource.EntityType.Name;

Check failure on line 171 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 171 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 171 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 171 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 171 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 171 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 171 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 171 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context
if(operationSegment.Operation.IsAction())
{
tagName += ".Actions";
}

if(operationSegment.Operation.IsFunction())
{
tagName += ".Functions";
}
break;
default:
tagName = NavigationSource.Name + "." + NavigationSource.EntityType().Name;
tagName = NavigationSource.Name + "." + NavigationSource.EntityType.Name;

Check failure on line 183 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 183 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 183 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 183 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Continuous Integration

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 183 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 183 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 183 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context

Check failure on line 183 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'ExtensionMethods.EntityType(IEdmEntityReferenceTypeReference)' is a method, which is not valid in the given context
break;
}
}
Expand Down Expand Up @@ -228,7 +234,7 @@
}
}

private void AppendSystemQueryOptions(IEdmFunction function, OpenApiOperation operation)

Check warning on line 237 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)

Check warning on line 237 in src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)
{
if (function.ReturnType.IsCollection())
{
Expand Down
Loading