Skip to content

Commit

Permalink
Fix: Examples into "x-examples" at models.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveira-michel committed Sep 30, 2021
1 parent 25eb288 commit 37fb1c0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Jhulis.Core/Rules/EmptyExamplesRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ private protected override void ExecuteRuleLogic()
//Here, we want at least one example at response type level
bool foundExample = response.Value.Content.Any(x =>
x.Value?.Schema?.Example != null
|| (x.Value?.Example != null)
|| (x.Value?.Examples != null && x.Value?.Examples.Count > 0)
|| (x.Value?.Schema?.Items?.Example != null));
|| x.Value?.Example != null
|| x.Value?.Examples != null && x.Value?.Examples.Count > 0
|| x.Value?.Schema?.Items?.Example != null
|| x.Value?.Schema?.Extensions?.TryGetValue("x-examples", out _) != false);

if (foundExample)
foreach (KeyValuePair<string, OpenApiMediaType> content in response.Value.Content)
Expand All @@ -64,9 +65,11 @@ private protected override void ExecuteRuleLogic()
//Here, we want at least one example at content level
bool foundExample = operation.Value?.RequestBody?.Content.Any(x =>
x.Value.Schema?.Example != null
|| (x.Value?.Example != null)
|| (x.Value?.Examples != null && x.Value.Examples.Count > 0)
|| (x.Value?.Schema?.Items?.Example != null)) == true;
|| x.Value?.Example != null
|| x.Value?.Examples != null && x.Value.Examples.Count > 0
|| x.Value?.Schema?.Items?.Example != null
|| x.Value?.Schema?.Extensions?.TryGetValue("x-examples", out _) != false
) == true;

if (foundExample)
foreach (KeyValuePair<string, OpenApiMediaType> content in operation.Value?.RequestBody?.Content)
Expand Down

0 comments on commit 37fb1c0

Please sign in to comment.