Skip to content

Commit

Permalink
Account for overloaded functions in any segment
Browse files Browse the repository at this point in the history
  • Loading branch information
irvinesunday committed Oct 1, 2024
1 parent 73de896 commit 75d4075
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected override void SetBasicInfo(OpenApiOperation operation)
// 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 @@ -101,6 +102,16 @@ protected override void SetBasicInfo(OpenApiOperation operation)
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 = segment.GetPathHash(Context.Settings);
}

identifiers.Add(segment.Identifier);
}
else
{
identifiers.Add(segment.Identifier);
Expand All @@ -109,21 +120,13 @@ protected override void SetBasicInfo(OpenApiOperation operation)

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

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

Expand Down

0 comments on commit 75d4075

Please sign in to comment.