Skip to content

Commit 219da17

Browse files
committed
Cleanup of ListNode
1 parent e7d874f commit 219da17

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

src/Microsoft.OpenApi.Readers/ParseNodes/ListNode.cs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,33 @@ public ListNode(ParsingContext context, OpenApiDiagnostic diagnostic, YamlSequen
2626

2727
public override List<T> CreateList<T>(Func<MapNode, T> map)
2828
{
29-
var yamlSequence = _nodeList;
30-
if (yamlSequence == null)
29+
if (_nodeList == null)
3130
{
3231
throw new OpenApiException(
3332
$"Expected list at line {_nodeList.Start.Line} while parsing {typeof(T).Name}");
3433
}
3534

36-
return yamlSequence.Select(n => map(new MapNode(Context, Diagnostic, n as YamlMappingNode)))
35+
return _nodeList.Select(n => map(new MapNode(Context, Diagnostic, n as YamlMappingNode)))
3736
.Where(i => i != null)
3837
.ToList();
3938
}
4039

4140
public override List<IOpenApiAny> CreateListOfAny()
4241
{
43-
var yamlSequence = _nodeList;
44-
if (yamlSequence == null)
45-
{
46-
throw new OpenApiException(
47-
$"Expected list at line {_nodeList.Start.Line}");
48-
}
49-
50-
return yamlSequence.Select(n => ParseNode.Create(Context, Diagnostic,n).CreateAny())
42+
return _nodeList.Select(n => ParseNode.Create(Context, Diagnostic,n).CreateAny())
5143
.Where(i => i != null)
5244
.ToList();
5345
}
5446

5547
public override List<T> CreateSimpleList<T>(Func<ValueNode, T> map)
5648
{
57-
var yamlSequence = _nodeList;
58-
if (yamlSequence == null)
49+
if (_nodeList == null)
5950
{
6051
throw new OpenApiException(
6152
$"Expected list at line {_nodeList.Start.Line} while parsing {typeof(T).Name}");
6253
}
6354

64-
return yamlSequence.Select(n => map(new ValueNode(Context, Diagnostic, (YamlScalarNode)n))).ToList();
55+
return _nodeList.Select(n => map(new ValueNode(Context, Diagnostic, (YamlScalarNode)n))).ToList();
6556
}
6657

6758
public IEnumerator<ParseNode> GetEnumerator()
@@ -88,10 +79,5 @@ public override IOpenApiAny CreateAny()
8879

8980
return array;
9081
}
91-
92-
//public override string GetScalarValue()
93-
//{
94-
// throw new OpenApiException()
95-
//}
9682
}
9783
}

src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ internal static partial class OpenApiV3Deserializer
109109
{
110110
"enum", (o, n) =>
111111
{
112-
o.Enum = n.CreateListOfAny(); }
112+
o.Enum = n.CreateListOfAny();
113+
}
113114
},
114115
{
115116
"type", (o, n) =>

0 commit comments

Comments
 (0)