Skip to content

Commit c9b8f4f

Browse files
committed
chore: apply copilot suggestion
1 parent 50b06c4 commit c9b8f4f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Microsoft.OpenApi/Reader/ParsingContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ public void PopLoop(string loopid)
271271

272272
private void ValidateRequiredFields(OpenApiDocument doc, string version)
273273
{
274-
if ((version.is2_0() || version.is3_0()) && (doc.Paths == null))
274+
if ((version.is2_0() || version.is3_0()) && (doc.Paths == null) && RootNode is not null)
275275
{
276276
// paths is a required field in OpenAPI 2.0 and 3.0 but optional in 3.1
277-
RootNode?.Context.Diagnostic.Errors.Add(new OpenApiError("", $"Paths is a REQUIRED field at {RootNode.Context.GetLocation()}"));
277+
RootNode.Context.Diagnostic.Errors.Add(new OpenApiError("", $"Paths is a REQUIRED field at {RootNode.Context.GetLocation()}"));
278278
}
279279
}
280280
}

0 commit comments

Comments
 (0)