Skip to content

Commit e3773e8

Browse files
committed
Merge branch 'main' into mk/upgrade-oai.net-to-v2
2 parents 471ba4f + b4bcdd2 commit e3773e8

13 files changed

+192
-89
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
- Further fix for generating unique operation ids for paths with composable overloaded functions where all functions in path are overloaded #594
3434
- Further fix for generating unique operation ids for navigation property paths with composable overloaded functions #596
3535
- Updates PUT operation id prefix from Update to Set #600
36+
- Adds action/function suffix to tag names for actions/functions operations #641
3637
</PackageReleaseNotes>
3738
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
3839
<AssemblyOriginatorKeyFile>..\..\tool\Microsoft.OpenApi.OData.snk</AssemblyOriginatorKeyFile>

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ protected override void SetTags(OpenApiOperation operation)
162162
}
163163

164164
/// <summary>
165-
/// Genrates the tag name for the operation.
165+
/// Genrates the tag name for the operation. Adds Action or Function name to the tag name if the operation is an action or function.
166166
/// </summary>
167167
/// <param name="tagName">The generated tag name.</param>
168168
/// <param name="skip">The number of segments to skip.</param>
@@ -175,16 +175,22 @@ private void GenerateTagName(out string tagName, int skip = 1)
175175
case ODataNavigationPropertySegment:
176176
tagName = EdmModelHelper.GenerateNavigationPropertyPathTagName(Path, Context);
177177
break;
178-
case ODataOperationSegment:
179178
case ODataOperationImportSegment:
180179
// Previous segmment could be a navigation property or a navigation source segment
181180
case ODataKeySegment:
182181
skip += 1;
183182
GenerateTagName(out tagName, skip);
184183
break;
185-
// ODataNavigationSourceSegment
186184
default:
187185
tagName = NavigationSource.Name + "." + NavigationSource.EntityType.Name;
186+
if (EdmOperation.IsAction())
187+
{
188+
tagName += ".Actions";
189+
}
190+
else if (EdmOperation.IsFunction())
191+
{
192+
tagName += ".Functions";
193+
}
188194
break;
189195
}
190196
}

test/Microsoft.OpenAPI.OData.Reader.Tests/Microsoft.OpenAPI.OData.Reader.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@
8080
</ItemGroup>
8181

8282
<ItemGroup>
83-
<PackageReference Include="coverlet.collector" Version="6.0.3">
83+
<PackageReference Include="coverlet.collector" Version="6.0.4">
8484
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
8585
<PrivateAssets>all</PrivateAssets>
8686
</PackageReference>
87-
<PackageReference Include="coverlet.msbuild" Version="6.0.3">
87+
<PackageReference Include="coverlet.msbuild" Version="6.0.4">
8888
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
8989
<PrivateAssets>all</PrivateAssets>
9090
</PackageReference>

test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EdmActionOperationHandlerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void CreateOperationForEdmActionReturnsCorrectOperation()
5050
Assert.Equal("Details of the shared trip.", operation.Description);
5151
Assert.NotNull(operation.Tags);
5252
var tag = Assert.Single(operation.Tags);
53-
Assert.Equal("People.Person", tag.Name);
53+
Assert.Equal("People.Person.Actions", tag.Name);
5454

5555
Assert.NotNull(operation.Parameters);
5656
Assert.Single(operation.Parameters);
@@ -90,7 +90,7 @@ public void CreateOperationForEdmActionReturnsCorrectOperationHierarchicalClass(
9090
Assert.Equal($"Invoke action {actionName}", operation.Summary);
9191
Assert.NotNull(operation.Tags);
9292
var tag = Assert.Single(operation.Tags);
93-
Assert.Equal($"{entitySetName}.AccountApiModel", tag.Name);
93+
Assert.Equal($"{entitySetName}.AccountApiModel.Actions", tag.Name);
9494

9595
Assert.NotNull(operation.Parameters);
9696
Assert.Single(operation.Parameters);

test/Microsoft.OpenAPI.OData.Reader.Tests/Operation/EdmFunctionOperationHandlerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void CreateOperationForEdmFunctionReturnsCorrectOperation(bool useHTTPSta
109109
Assert.Equal("Invoke function GetFavoriteAirline", operation.Summary);
110110
Assert.NotNull(operation.Tags);
111111
var tag = Assert.Single(operation.Tags);
112-
Assert.Equal("People.Person", tag.Name);
112+
Assert.Equal("People.Person.Functions", tag.Name);
113113

114114
Assert.NotNull(operation.Parameters);
115115
Assert.Single(operation.Parameters);
@@ -148,7 +148,7 @@ public void CreateOperationForEdmFunctionReturnsCorrectOperationHierarchicalClas
148148
Assert.Equal("Collection of contract attachments.", operation.Description);
149149
Assert.NotNull(operation.Tags);
150150
var tag = Assert.Single(operation.Tags);
151-
Assert.Equal($"{entitySetName}.AccountApiModel", tag.Name);
151+
Assert.Equal($"{entitySetName}.AccountApiModel.Functions", tag.Name);
152152

153153
Assert.NotNull(operation.Parameters);
154154
Assert.Equal(6, operation.Parameters.Count); // id, top, skip, count, search, filter

test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Multiple.Schema.OpenApi.V2.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@
591591
"/Documents({Id})/Default.Upload": {
592592
"post": {
593593
"tags": [
594-
"Documents.DocumentDto"
594+
"Documents.DocumentDto.Actions"
595595
],
596596
"summary": "Invoke action Upload",
597597
"operationId": "Documents.DocumentDto.Upload",
@@ -3519,7 +3519,7 @@
35193519
"/Tasks({Id})/Default.Upload": {
35203520
"post": {
35213521
"tags": [
3522-
"Tasks.DocumentDto"
3522+
"Tasks.DocumentDto.Actions"
35233523
],
35243524
"summary": "Invoke action Upload",
35253525
"operationId": "Tasks.DocumentDto.Upload",
@@ -6277,6 +6277,10 @@
62776277
"name": "Documents.DocumentDto",
62786278
"x-ms-docs-toc-type": "page"
62796279
},
6280+
{
6281+
"name": "Documents.DocumentDto.Actions",
6282+
"x-ms-docs-toc-type": "container"
6283+
},
62806284
{
62816285
"name": "Documents.RevisionDto",
62826286
"x-ms-docs-toc-type": "page"
@@ -6317,6 +6321,10 @@
63176321
"name": "Tasks.DocumentDto",
63186322
"x-ms-docs-toc-type": "page"
63196323
},
6324+
{
6325+
"name": "Tasks.DocumentDto.Actions",
6326+
"x-ms-docs-toc-type": "container"
6327+
},
63206328
{
63216329
"name": "Tasks.RevisionDto",
63226330
"x-ms-docs-toc-type": "page"

test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Multiple.Schema.OpenApi.V2.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ paths:
413413
'/Documents({Id})/Default.Upload':
414414
post:
415415
tags:
416-
- Documents.DocumentDto
416+
- Documents.DocumentDto.Actions
417417
summary: Invoke action Upload
418418
operationId: Documents.DocumentDto.Upload
419419
parameters:
@@ -2495,7 +2495,7 @@ paths:
24952495
'/Tasks({Id})/Default.Upload':
24962496
post:
24972497
tags:
2498-
- Tasks.DocumentDto
2498+
- Tasks.DocumentDto.Actions
24992499
summary: Invoke action Upload
25002500
operationId: Tasks.DocumentDto.Upload
25012501
parameters:
@@ -4547,6 +4547,8 @@ tags:
45474547
x-ms-docs-toc-type: page
45484548
- name: Documents.DocumentDto
45494549
x-ms-docs-toc-type: page
4550+
- name: Documents.DocumentDto.Actions
4551+
x-ms-docs-toc-type: container
45504552
- name: Documents.RevisionDto
45514553
x-ms-docs-toc-type: page
45524554
- name: Documents.DocumentTagRelDto
@@ -4567,6 +4569,8 @@ tags:
45674569
x-ms-docs-toc-type: page
45684570
- name: Tasks.DocumentDto
45694571
x-ms-docs-toc-type: page
4572+
- name: Tasks.DocumentDto.Actions
4573+
x-ms-docs-toc-type: container
45704574
- name: Tasks.RevisionDto
45714575
x-ms-docs-toc-type: page
45724576
- name: Tasks.DocumentTagRelDto

test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Multiple.Schema.OpenApi.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@
663663
"description": "Provides operations to call the Upload method.",
664664
"post": {
665665
"tags": [
666-
"Documents.DocumentDto"
666+
"Documents.DocumentDto.Actions"
667667
],
668668
"summary": "Invoke action Upload",
669669
"operationId": "Documents.DocumentDto.Upload",
@@ -3940,7 +3940,7 @@
39403940
"description": "Provides operations to call the Upload method.",
39413941
"post": {
39423942
"tags": [
3943-
"Tasks.DocumentDto"
3943+
"Tasks.DocumentDto.Actions"
39443944
],
39453945
"summary": "Invoke action Upload",
39463946
"operationId": "Tasks.DocumentDto.Upload",
@@ -7507,6 +7507,10 @@
75077507
"name": "Documents.DocumentDto",
75087508
"x-ms-docs-toc-type": "page"
75097509
},
7510+
{
7511+
"name": "Documents.DocumentDto.Actions",
7512+
"x-ms-docs-toc-type": "container"
7513+
},
75107514
{
75117515
"name": "Documents.RevisionDto",
75127516
"x-ms-docs-toc-type": "page"
@@ -7547,6 +7551,10 @@
75477551
"name": "Tasks.DocumentDto",
75487552
"x-ms-docs-toc-type": "page"
75497553
},
7554+
{
7555+
"name": "Tasks.DocumentDto.Actions",
7556+
"x-ms-docs-toc-type": "container"
7557+
},
75507558
{
75517559
"name": "Tasks.RevisionDto",
75527560
"x-ms-docs-toc-type": "page"

test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Multiple.Schema.OpenApi.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ paths:
460460
description: Provides operations to call the Upload method.
461461
post:
462462
tags:
463-
- Documents.DocumentDto
463+
- Documents.DocumentDto.Actions
464464
summary: Invoke action Upload
465465
operationId: Documents.DocumentDto.Upload
466466
parameters:
@@ -2771,7 +2771,7 @@ paths:
27712771
description: Provides operations to call the Upload method.
27722772
post:
27732773
tags:
2774-
- Tasks.DocumentDto
2774+
- Tasks.DocumentDto.Actions
27752775
summary: Invoke action Upload
27762776
operationId: Tasks.DocumentDto.Upload
27772777
parameters:
@@ -5410,6 +5410,8 @@ tags:
54105410
x-ms-docs-toc-type: page
54115411
- name: Documents.DocumentDto
54125412
x-ms-docs-toc-type: page
5413+
- name: Documents.DocumentDto.Actions
5414+
x-ms-docs-toc-type: container
54135415
- name: Documents.RevisionDto
54145416
x-ms-docs-toc-type: page
54155417
- name: Documents.DocumentTagRelDto
@@ -5430,6 +5432,8 @@ tags:
54305432
x-ms-docs-toc-type: page
54315433
- name: Tasks.DocumentDto
54325434
x-ms-docs-toc-type: page
5435+
- name: Tasks.DocumentDto.Actions
5436+
x-ms-docs-toc-type: container
54335437
- name: Tasks.RevisionDto
54345438
x-ms-docs-toc-type: page
54355439
- name: Tasks.DocumentTagRelDto

0 commit comments

Comments
 (0)