6
6
using System . Collections . Generic ;
7
7
using System . Linq ;
8
8
using Microsoft . OpenApi . Any ;
9
- using Microsoft . OpenApi . Exceptions ;
10
9
using Microsoft . OpenApi . Interfaces ;
11
10
using Microsoft . OpenApi . Models ;
12
11
using Microsoft . OpenApi . Readers . Exceptions ;
@@ -33,7 +32,7 @@ public MapNode(ParsingContext context, YamlNode node) : base(
33
32
{
34
33
if ( ! ( node is YamlMappingNode mapNode ) )
35
34
{
36
- throw new OpenApiReaderException ( "Expected map." , node ) ;
35
+ throw new OpenApiReaderException ( "Expected map." , Context ) ;
37
36
}
38
37
39
38
this . _node = mapNode ;
@@ -48,10 +47,10 @@ public PropertyNode this[string key]
48
47
{
49
48
get
50
49
{
51
- YamlNode node = null ;
50
+ YamlNode node ;
52
51
if ( this . _node . Children . TryGetValue ( new YamlScalarNode ( key ) , out node ) )
53
52
{
54
- return new PropertyNode ( Context , key , this . _node . Children [ new YamlScalarNode ( key ) ] ) ;
53
+ return new PropertyNode ( Context , key , node ) ;
55
54
}
56
55
57
56
return null ;
@@ -63,7 +62,7 @@ public override Dictionary<string, T> CreateMap<T>(Func<MapNode, T> map)
63
62
var yamlMap = _node ;
64
63
if ( yamlMap == null )
65
64
{
66
- throw new OpenApiReaderException ( $ "Expected map at line { yamlMap . Start . Line } while parsing { typeof ( T ) . Name } ", yamlMap ) ;
65
+ throw new OpenApiReaderException ( $ "Expected map while parsing { typeof ( T ) . Name } ", Context ) ;
67
66
}
68
67
69
68
var nodes = yamlMap . Select (
@@ -99,7 +98,7 @@ public override Dictionary<string, T> CreateMapWithReference<T>(
99
98
var yamlMap = _node ;
100
99
if ( yamlMap == null )
101
100
{
102
- throw new OpenApiReaderException ( $ "Expected map at line { yamlMap . Start . Line } while parsing { typeof ( T ) . Name } ", yamlMap ) ;
101
+ throw new OpenApiReaderException ( $ "Expected map while parsing { typeof ( T ) . Name } ", Context ) ;
103
102
}
104
103
105
104
var nodes = yamlMap . Select (
@@ -133,8 +132,8 @@ public override Dictionary<string, T> CreateSimpleMap<T>(Func<ValueNode, T> map)
133
132
{
134
133
var yamlMap = _node ;
135
134
if ( yamlMap == null )
136
- {
137
- throw new OpenApiReaderException ( $ "Expected map at line { yamlMap . Start . Line } while parsing { typeof ( T ) . Name } ", yamlMap ) ;
135
+ {
136
+ throw new OpenApiReaderException ( $ "Expected map while parsing { typeof ( T ) . Name } ", Context ) ;
138
137
}
139
138
140
139
var nodes = yamlMap . Select (
@@ -189,7 +188,7 @@ public string GetScalarValue(ValueNode key)
189
188
var scalarNode = _node . Children [ new YamlScalarNode ( key . GetScalarValue ( ) ) ] as YamlScalarNode ;
190
189
if ( scalarNode == null )
191
190
{
192
- throw new OpenApiReaderException ( $ "Expected scalar at line { _node . Start . Line } for key { key . GetScalarValue ( ) } ", _node ) ;
191
+ throw new OpenApiReaderException ( $ "Expected scalar at line { _node . Start . Line } for key { key . GetScalarValue ( ) } ", Context ) ;
193
192
}
194
193
195
194
return scalarNode . Value ;
0 commit comments