Skip to content

Commit 0bd881b

Browse files
committed
Refactor code
1 parent 63570c1 commit 0bd881b

21 files changed

+153
-968
lines changed

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,8 @@ IEnumerator IEnumerable.GetEnumerator()
6565
/// </summary>
6666
/// <returns>The created Any object.</returns>
6767
public override OpenApiAny CreateAny()
68-
{
69-
var array = new JsonArray();
70-
foreach (var node in this)
71-
{
72-
array.Add(node.CreateAny().Node);
73-
}
74-
75-
return new OpenApiAny(array);
68+
{
69+
return new OpenApiAny(_nodeList);
7670
}
7771
}
7872
}

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,19 +190,12 @@ public string GetScalarValue(ValueNode key)
190190
}
191191

192192
/// <summary>
193-
/// Create a <see cref="JsonObject"/>
193+
/// Create an <see cref="OpenApiAny"/>
194194
/// </summary>
195195
/// <returns>The created Json object.</returns>
196196
public override OpenApiAny CreateAny()
197-
{
198-
var apiObject = new JsonObject();
199-
foreach (var node in this)
200-
{
201-
var jsonNode = node.Value.CreateAny().Node;
202-
apiObject.Add(node.Name, jsonNode);
203-
}
204-
205-
return new OpenApiAny(apiObject);
197+
{
198+
return new OpenApiAny(_node);
206199
}
207200
}
208201
}

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

Lines changed: 0 additions & 301 deletions
This file was deleted.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ public RootNode(
2323

2424
public ParseNode Find(JsonPointer referencePointer)
2525
{
26-
var jsonNode = referencePointer.Find(_jsonNode) is JsonNode node ? node : null;
26+
if (referencePointer.Find(_jsonNode) is not JsonNode jsonNode)
27+
{
28+
return null;
29+
}
2730

2831
return Create(Context, jsonNode);
2932
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public override string GetScalarValue()
3434
/// <returns>The created Any object.</returns>
3535
public override OpenApiAny CreateAny()
3636
{
37-
var value = GetScalarValue();
38-
return new OpenApiAny(value);
37+
return new OpenApiAny(_node);
3938
}
4039
}
4140
}

0 commit comments

Comments
 (0)