Skip to content

Commit ea589d3

Browse files
authored
Merge pull request #641 from microsoft/tm/fix-operation-tag-names
Adds action/function suffix to tag names for action/function operations
2 parents 0b77ca3 + ef72b9e commit ea589d3

12 files changed

+190
-87
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
@@ -152,7 +152,7 @@ protected override void SetTags(OpenApiOperation operation)
152152
}
153153

154154
/// <summary>
155-
/// Genrates the tag name for the operation.
155+
/// Genrates the tag name for the operation. Adds Action or Function name to the tag name if the operation is an action or function.
156156
/// </summary>
157157
/// <param name="tagName">The generated tag name.</param>
158158
/// <param name="skip">The number of segments to skip.</param>
@@ -165,16 +165,22 @@ private void GenerateTagName(out string tagName, int skip = 1)
165165
case ODataNavigationPropertySegment:
166166
tagName = EdmModelHelper.GenerateNavigationPropertyPathTagName(Path, Context);
167167
break;
168-
case ODataOperationSegment:
169168
case ODataOperationImportSegment:
170169
// Previous segmment could be a navigation property or a navigation source segment
171170
case ODataKeySegment:
172171
skip += 1;
173172
GenerateTagName(out tagName, skip);
174173
break;
175-
// ODataNavigationSourceSegment
176174
default:
177175
tagName = NavigationSource.Name + "." + NavigationSource.EntityType.Name;
176+
if (EdmOperation.IsAction())
177+
{
178+
tagName += ".Actions";
179+
}
180+
else if (EdmOperation.IsFunction())
181+
{
182+
tagName += ".Functions";
183+
}
178184
break;
179185
}
180186
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void CreateOperationForEdmActionReturnsCorrectOperation()
4040
Assert.Equal("Details of the shared trip.", operation.Description);
4141
Assert.NotNull(operation.Tags);
4242
var tag = Assert.Single(operation.Tags);
43-
Assert.Equal("People.Person", tag.Name);
43+
Assert.Equal("People.Person.Actions", tag.Name);
4444

4545
Assert.NotNull(operation.Parameters);
4646
Assert.Single(operation.Parameters);
@@ -79,7 +79,7 @@ public void CreateOperationForEdmActionReturnsCorrectOperationHierarchicalClass(
7979
Assert.Equal($"Invoke action {actionName}", operation.Summary);
8080
Assert.NotNull(operation.Tags);
8181
var tag = Assert.Single(operation.Tags);
82-
Assert.Equal($"{entitySetName}.AccountApiModel", tag.Name);
82+
Assert.Equal($"{entitySetName}.AccountApiModel.Actions", tag.Name);
8383

8484
Assert.NotNull(operation.Parameters);
8585
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
@@ -100,7 +100,7 @@ public void CreateOperationForEdmFunctionReturnsCorrectOperation(bool useHTTPSta
100100
Assert.Equal("Invoke function GetFavoriteAirline", operation.Summary);
101101
Assert.NotNull(operation.Tags);
102102
var tag = Assert.Single(operation.Tags);
103-
Assert.Equal("People.Person", tag.Name);
103+
Assert.Equal("People.Person.Functions", tag.Name);
104104

105105
Assert.NotNull(operation.Parameters);
106106
Assert.Single(operation.Parameters);
@@ -138,7 +138,7 @@ public void CreateOperationForEdmFunctionReturnsCorrectOperationHierarchicalClas
138138
Assert.Equal("Collection of contract attachments.", operation.Description);
139139
Assert.NotNull(operation.Tags);
140140
var tag = Assert.Single(operation.Tags);
141-
Assert.Equal($"{entitySetName}.AccountApiModel", tag.Name);
141+
Assert.Equal($"{entitySetName}.AccountApiModel.Functions", tag.Name);
142142

143143
Assert.NotNull(operation.Parameters);
144144
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",
@@ -6275,6 +6275,10 @@
62756275
"name": "Documents.DocumentDto",
62766276
"x-ms-docs-toc-type": "page"
62776277
},
6278+
{
6279+
"name": "Documents.DocumentDto.Actions",
6280+
"x-ms-docs-toc-type": "container"
6281+
},
62786282
{
62796283
"name": "Documents.RevisionDto",
62806284
"x-ms-docs-toc-type": "page"
@@ -6315,6 +6319,10 @@
63156319
"name": "Tasks.DocumentDto",
63166320
"x-ms-docs-toc-type": "page"
63176321
},
6322+
{
6323+
"name": "Tasks.DocumentDto.Actions",
6324+
"x-ms-docs-toc-type": "container"
6325+
},
63186326
{
63196327
"name": "Tasks.RevisionDto",
63206328
"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:
@@ -4545,6 +4545,8 @@ tags:
45454545
x-ms-docs-toc-type: page
45464546
- name: Documents.DocumentDto
45474547
x-ms-docs-toc-type: page
4548+
- name: Documents.DocumentDto.Actions
4549+
x-ms-docs-toc-type: container
45484550
- name: Documents.RevisionDto
45494551
x-ms-docs-toc-type: page
45504552
- name: Documents.DocumentTagRelDto
@@ -4565,6 +4567,8 @@ tags:
45654567
x-ms-docs-toc-type: page
45664568
- name: Tasks.DocumentDto
45674569
x-ms-docs-toc-type: page
4570+
- name: Tasks.DocumentDto.Actions
4571+
x-ms-docs-toc-type: container
45684572
- name: Tasks.RevisionDto
45694573
x-ms-docs-toc-type: page
45704574
- 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",
@@ -7481,6 +7481,10 @@
74817481
"name": "Documents.DocumentDto",
74827482
"x-ms-docs-toc-type": "page"
74837483
},
7484+
{
7485+
"name": "Documents.DocumentDto.Actions",
7486+
"x-ms-docs-toc-type": "container"
7487+
},
74847488
{
74857489
"name": "Documents.RevisionDto",
74867490
"x-ms-docs-toc-type": "page"
@@ -7521,6 +7525,10 @@
75217525
"name": "Tasks.DocumentDto",
75227526
"x-ms-docs-toc-type": "page"
75237527
},
7528+
{
7529+
"name": "Tasks.DocumentDto.Actions",
7530+
"x-ms-docs-toc-type": "container"
7531+
},
75247532
{
75257533
"name": "Tasks.RevisionDto",
75267534
"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:
@@ -5384,6 +5384,8 @@ tags:
53845384
x-ms-docs-toc-type: page
53855385
- name: Documents.DocumentDto
53865386
x-ms-docs-toc-type: page
5387+
- name: Documents.DocumentDto.Actions
5388+
x-ms-docs-toc-type: container
53875389
- name: Documents.RevisionDto
53885390
x-ms-docs-toc-type: page
53895391
- name: Documents.DocumentTagRelDto
@@ -5404,6 +5406,8 @@ tags:
54045406
x-ms-docs-toc-type: page
54055407
- name: Tasks.DocumentDto
54065408
x-ms-docs-toc-type: page
5409+
- name: Tasks.DocumentDto.Actions
5410+
x-ms-docs-toc-type: container
54075411
- name: Tasks.RevisionDto
54085412
x-ms-docs-toc-type: page
54095413
- name: Tasks.DocumentTagRelDto

0 commit comments

Comments
 (0)