Skip to content

Commit 8646818

Browse files
irvinesundayandrueastman
authored andcommitted
Updates tag names for actions/functions operations (#586)
* Update operation tags generation * Refactor operation tag generation * Update unit tests * Update integration test files * Update release note * Update src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs Co-authored-by: Andrew Omondi <[email protected]> * Account for nullability * Remove unnecessary code --------- Co-authored-by: Andrew Omondi <[email protected]>
1 parent 4db0cbc commit 8646818

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@
2121
<PackageTags>Microsoft OpenApi OData EDM</PackageTags>
2222
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET.OData</RepositoryUrl>
2323
<PackageReleaseNotes>
24-
- Further fix for generating unique operation ids for navigation property paths with composable overloaded functions #596
25-
</PackageReleaseNotes>
24+
- Upgraded to Microsoft.Odata.Edm 8.0.0
25+
- Cleaned up obsolete APIs
26+
- Changed target framework to net8.0
27+
- Adds support for retrieving collection of enum values from UpdateMethod property of UpdateRestrictions annotation #564
28+
- Adds nullable to double schema conversions #581
29+
- Updates tag names for actions/functions operations #585
30+
</PackageReleaseNotes>
2631
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
2732
<AssemblyOriginatorKeyFile>..\..\tool\Microsoft.OpenApi.OData.snk</AssemblyOriginatorKeyFile>
2833
<OutputPath Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">..\..\bin\Debug\</OutputPath>

src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ protected override void SetBasicInfo(OpenApiOperation operation)
8181
// duplicates in entity vs entityset functions/actions
8282

8383
List<string> identifiers = new();
84-
string pathHash = string.Empty;
8584
foreach (ODataSegment segment in Path.Segments)
8685
{
8786
if (segment is ODataKeySegment keySegment)
@@ -102,18 +101,6 @@ protected override void SetBasicInfo(OpenApiOperation operation)
102101
identifiers.Add(keySegment.Identifier);
103102
}
104103
}
105-
else if (segment is ODataOperationSegment opSegment)
106-
{
107-
if (opSegment.Operation is IEdmFunction function && Context.Model.IsOperationOverload(function))
108-
{
109-
// Hash the segment to avoid duplicate operationIds
110-
pathHash = string.IsNullOrEmpty(pathHash)
111-
? opSegment.GetPathHash(Context.Settings)
112-
: (pathHash + opSegment.GetPathHash(Context.Settings)).GetHashSHA256().Substring(0, 4);
113-
}
114-
115-
identifiers.Add(segment.Identifier);
116-
}
117104
else
118105
{
119106
identifiers.Add(segment.Identifier);
@@ -122,13 +109,21 @@ protected override void SetBasicInfo(OpenApiOperation operation)
122109

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

125-
if (!string.IsNullOrEmpty(pathHash))
112+
if (EdmOperation.IsAction())
126113
{
127-
operation.OperationId = operationId + "-" + pathHash;
114+
operation.OperationId = operationId;
128115
}
129116
else
130117
{
131-
operation.OperationId = operationId;
118+
if (Path.LastSegment is ODataOperationSegment operationSegment &&
119+
Context.Model.IsOperationOverload(operationSegment.Operation))
120+
{
121+
operation.OperationId = operationId + "-" + Path.LastSegment.GetPathHash(Context.Settings);
122+
}
123+
else
124+
{
125+
operation.OperationId = operationId;
126+
}
132127
}
133128
}
134129

@@ -174,7 +169,7 @@ private void GenerateTagName(out string tagName, int skip = 1)
174169
break;
175170
// ODataNavigationSourceSegment
176171
default:
177-
tagName = NavigationSource.Name + "." + NavigationSource.EntityType().Name;
172+
tagName = NavigationSource.Name + "." + NavigationSource.EntityType.Name;
178173
break;
179174
}
180175
}

0 commit comments

Comments
 (0)