Skip to content

Commit 823cf10

Browse files
Combine if statements
Combine if statements to resolve CodeQL suggestion.
1 parent a50ed00 commit 823cf10

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/TodoApp/OpenApi/ExamplesProcessor.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,11 @@ private static void TryAddParameterExamples(
7878
argument.ParameterType.GetExampleMetadata().FirstOrDefault((p) => p.SchemaType == argument.ParameterType) ??
7979
examples.FirstOrDefault((p) => p.SchemaType == argument.ParameterType);
8080

81-
if (metadata?.GenerateExample(Context) is { } value)
81+
// Find the parameter that corresponds to the argument and set its example
82+
if (metadata?.GenerateExample(Context) is { } value &&
83+
parameters.FirstOrDefault((p) => p.Name == argument.Name) is OpenApiParameter parameter)
8284
{
83-
// Find the parameter that corresponds to the argument and set its example
84-
if (parameters.FirstOrDefault((p) => p.Name == argument.Name) is OpenApiParameter parameter)
85-
{
86-
parameter.Example ??= value;
87-
}
85+
parameter.Example ??= value;
8886
}
8987
}
9088
}

0 commit comments

Comments
 (0)