@@ -23,14 +23,13 @@ internal class MapNode : ParseNode, IEnumerable<PropertyNode>
2323 private readonly YamlMappingNode _node ;
2424 private readonly List < PropertyNode > _nodes ;
2525
26- public MapNode ( ParsingContext context , OpenApiDiagnostic diagnostic , string yamlString ) :
27- this ( context , diagnostic , ( YamlMappingNode ) YamlHelper . ParseYamlString ( yamlString ) )
26+ public MapNode ( ParsingContext context , string yamlString ) :
27+ this ( context , ( YamlMappingNode ) YamlHelper . ParseYamlString ( yamlString ) )
2828 {
2929 }
3030
31- public MapNode ( ParsingContext context , OpenApiDiagnostic diagnostic , YamlNode node ) : base (
32- context ,
33- diagnostic )
31+ public MapNode ( ParsingContext context , YamlNode node ) : base (
32+ context )
3433 {
3534 if ( ! ( node is YamlMappingNode mapNode ) )
3635 {
@@ -40,7 +39,7 @@ public MapNode(ParsingContext context, OpenApiDiagnostic diagnostic, YamlNode no
4039 this . _node = mapNode ;
4140
4241 _nodes = this . _node . Children
43- . Select ( kvp => new PropertyNode ( Context , Diagnostic , kvp . Key . GetScalarValue ( ) , kvp . Value ) )
42+ . Select ( kvp => new PropertyNode ( Context , kvp . Key . GetScalarValue ( ) , kvp . Value ) )
4443 . Cast < PropertyNode > ( )
4544 . ToList ( ) ;
4645 }
@@ -52,7 +51,7 @@ public PropertyNode this[string key]
5251 YamlNode node = null ;
5352 if ( this . _node . Children . TryGetValue ( new YamlScalarNode ( key ) , out node ) )
5453 {
55- return new PropertyNode ( Context , Diagnostic , key , this . _node . Children [ new YamlScalarNode ( key ) ] ) ;
54+ return new PropertyNode ( Context , key , this . _node . Children [ new YamlScalarNode ( key ) ] ) ;
5655 }
5756
5857 return null ;
@@ -73,43 +72,44 @@ public override Dictionary<string, T> CreateMap<T>(Func<MapNode, T> map)
7372 key = n . Key . GetScalarValue ( ) ,
7473 value = n . Value as YamlMappingNode == null
7574 ? default ( T )
76- : map ( new MapNode ( Context , Diagnostic , n . Value as YamlMappingNode ) )
75+ : map ( new MapNode ( Context , n . Value as YamlMappingNode ) )
7776 } ) ;
7877
7978 return nodes . ToDictionary ( k => k . key , v => v . value ) ;
8079 }
8180
82- public override Dictionary < string , T > CreateMapWithReference < T > (
83- ReferenceType referenceType ,
84- Func < MapNode , T > map )
85- {
86- var yamlMap = _node ;
87- if ( yamlMap == null )
88- {
89- throw new OpenApiException ( $ "Expected map at line { yamlMap . Start . Line } while parsing { typeof ( T ) . Name } ") ;
90- }
91-
92- var nodes = yamlMap . Select (
93- n => {
94- var entry = new
95- {
96- key = n . Key . GetScalarValue ( ) ,
97- value = map ( new MapNode ( Context , Diagnostic , ( YamlMappingNode ) n . Value ) )
98- } ;
99- if ( entry . value == null )
100- {
101- return null ; // Body Parameters shouldn't be converted to Parameters
102- }
103- entry . value . Reference = new OpenApiReference ( )
104- {
105- Type = referenceType ,
106- Id = entry . key
107- } ;
108- return entry ;
109- }
110- ) ;
111- return nodes . Where ( n => n != null ) . ToDictionary ( k => k . key , v => v . value ) ;
112- }
81+ public override Dictionary < string , T > CreateMapWithReference < T > (
82+ ReferenceType referenceType ,
83+ Func < MapNode , T > map )
84+ {
85+ var yamlMap = _node ;
86+ if ( yamlMap == null )
87+ {
88+ throw new OpenApiException ( $ "Expected map at line { yamlMap . Start . Line } while parsing { typeof ( T ) . Name } ") ;
89+ }
90+
91+ var nodes = yamlMap . Select (
92+ n =>
93+ {
94+ var entry = new
95+ {
96+ key = n . Key . GetScalarValue ( ) ,
97+ value = map ( new MapNode ( Context , ( YamlMappingNode ) n . Value ) )
98+ } ;
99+ if ( entry . value == null )
100+ {
101+ return null ; // Body Parameters shouldn't be converted to Parameters
102+ }
103+ entry . value . Reference = new OpenApiReference ( )
104+ {
105+ Type = referenceType ,
106+ Id = entry . key
107+ } ;
108+ return entry ;
109+ }
110+ ) ;
111+ return nodes . Where ( n => n != null ) . ToDictionary ( k => k . key , v => v . value ) ;
112+ }
113113
114114 public override Dictionary < string , T > CreateSimpleMap < T > ( Func < ValueNode , T > map )
115115 {
@@ -123,7 +123,7 @@ public override Dictionary<string, T> CreateSimpleMap<T>(Func<ValueNode, T> map)
123123 n => new
124124 {
125125 key = n . Key . GetScalarValue ( ) ,
126- value = map ( new ValueNode ( Context , Diagnostic , ( YamlScalarNode ) n . Value ) )
126+ value = map ( new ValueNode ( Context , ( YamlScalarNode ) n . Value ) )
127127 } ) ;
128128 return nodes . ToDictionary ( k => k . key , v => v . value ) ;
129129 }
@@ -140,18 +140,18 @@ IEnumerator IEnumerable.GetEnumerator()
140140
141141 public override string GetRaw ( )
142142 {
143- var x = new Serializer ( new SerializerSettings ( new JsonSchema ( ) ) { EmitJsonComptible = true } ) ;
143+ var x = new Serializer ( new SerializerSettings ( new JsonSchema ( ) ) { EmitJsonComptible = true } ) ;
144144 return x . Serialize ( _node ) ;
145145 }
146146
147147 public T GetReferencedObject < T > ( ReferenceType referenceType , string referenceId )
148148 where T : IOpenApiReferenceable , new ( )
149149 {
150150 return new T ( )
151- {
152- UnresolvedReference = true ,
153- Reference = Context . VersionService . ConvertToOpenApiReference ( referenceId , referenceType )
154- } ;
151+ {
152+ UnresolvedReference = true ,
153+ Reference = Context . VersionService . ConvertToOpenApiReference ( referenceId , referenceType )
154+ } ;
155155 }
156156
157157 public string GetReferencePointer ( )
0 commit comments