Skip to content

Commit c15a309

Browse files
committed
- code linting
Signed-off-by: Vincent Biret <[email protected]>
1 parent 22ddc2c commit c15a309

File tree

1 file changed

+22
-30
lines changed

1 file changed

+22
-30
lines changed

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

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -101,33 +101,29 @@ protected override void SetTags(OpenApiOperation operation)
101101
NavigationSource.Name
102102
};
103103

104-
foreach (var segment in Path.Segments.Skip(1))
104+
foreach (var segment in Path.Segments.Skip(1).OfType<ODataNavigationPropertySegment>())
105105
{
106-
ODataNavigationPropertySegment npSegment = segment as ODataNavigationPropertySegment;
107-
if (npSegment != null)
106+
if (segment.NavigationProperty == NavigationProperty)
108107
{
109-
if (npSegment.NavigationProperty == NavigationProperty)
108+
items.Add(NavigationProperty.ToEntityType().Name);
109+
break;
110+
}
111+
else
112+
{
113+
if (items.Count >= Context.Settings.TagDepth - 1)
110114
{
111-
items.Add(NavigationProperty.ToEntityType().Name);
115+
items.Add(segment.NavigationProperty.ToEntityType().Name);
112116
break;
113117
}
114118
else
115119
{
116-
if (items.Count >= Context.Settings.TagDepth - 1)
117-
{
118-
items.Add(npSegment.NavigationProperty.ToEntityType().Name);
119-
break;
120-
}
121-
else
122-
{
123-
items.Add(npSegment.NavigationProperty.Name);
124-
}
120+
items.Add(segment.NavigationProperty.Name);
125121
}
126122
}
127123
}
128124

129125
string name = string.Join(".", items);
130-
OpenApiTag tag = new OpenApiTag
126+
OpenApiTag tag = new()
131127
{
132128
Name = name
133129
};
@@ -155,28 +151,24 @@ protected string GetOperationId(string prefix = null)
155151
};
156152

157153
var lastpath = Path.Segments.Last(c => c is ODataNavigationPropertySegment);
158-
foreach (var segment in Path.Segments.Skip(1))
154+
foreach (var segment in Path.Segments.Skip(1).OfType<ODataNavigationPropertySegment>())
159155
{
160-
ODataNavigationPropertySegment npSegment = segment as ODataNavigationPropertySegment;
161-
if (npSegment != null)
156+
if (segment == lastpath)
162157
{
163-
if (segment == lastpath)
158+
if (prefix != null)
164159
{
165-
if (prefix != null)
166-
{
167-
items.Add(prefix + Utils.UpperFirstChar(npSegment.NavigationProperty.Name));
168-
}
169-
else
170-
{
171-
items.Add(Utils.UpperFirstChar(npSegment.NavigationProperty.Name));
172-
}
173-
174-
break;
160+
items.Add(prefix + Utils.UpperFirstChar(segment.NavigationProperty.Name));
175161
}
176162
else
177163
{
178-
items.Add(npSegment.NavigationProperty.Name);
164+
items.Add(Utils.UpperFirstChar(segment.NavigationProperty.Name));
179165
}
166+
167+
break;
168+
}
169+
else
170+
{
171+
items.Add(segment.NavigationProperty.Name);
180172
}
181173
}
182174

0 commit comments

Comments
 (0)