Skip to content

Commit deae283

Browse files
committed
Merge if with the outer else if statement
1 parent 0223425 commit deae283

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/Microsoft.OpenApi.Readers/ParsingContext.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,10 @@ private void ValidateRequiredFields(OpenApiDocument doc, string version)
253253
// paths is a required field in OpenAPI 3.0 but optional in 3.1
254254
RootNode.Context.Diagnostic.Errors.Add(new OpenApiError("", $"Paths is a REQUIRED field at {RootNode.Context.GetLocation()}"));
255255
}
256-
else if (version.StartsWith("3.1"))
256+
else if (version.StartsWith("3.1") && (doc.Paths == null || !doc.Paths.Any()) && (doc.Webhooks == null || !doc.Webhooks.Any()))
257257
{
258-
if ((doc.Paths == null || !doc.Paths.Any()) && (doc.Webhooks == null || !doc.Webhooks.Any()))
259-
{
260-
RootNode.Context.Diagnostic.Errors.Add(new OpenApiError(
261-
"", $"The document MUST contain either a Paths or Webhooks field at {RootNode.Context.GetLocation()}"));
262-
}
258+
RootNode.Context.Diagnostic.Errors.Add(new OpenApiError(
259+
"", $"The document MUST contain either a Paths or Webhooks field at {RootNode.Context.GetLocation()}"));
263260
}
264261
}
265262
}

0 commit comments

Comments
 (0)