Skip to content

Commit

Permalink
Fix: Error when array type is not declared.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveira-michel committed Oct 14, 2021
1 parent 488c773 commit db98f61
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Jhulis.Core/Helpers/Extensions/OpenApiDocumentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using Jhulis.Core;
using Jhulis.Core.Exceptions;

namespace Jhulis.Core.Helpers.Extensions
{
Expand Down Expand Up @@ -147,6 +148,16 @@ public string ResultLocation()

if (!hittedMaxDepth)
{
if (property.Value.Type == "array"
&& property.Value?.Items?.Properties == null
|| property.Value?.Items?.Properties.Count == 0
)
{
throw new InvalidOpenApiDocumentException(
$"The property {property.Key} is declared as array, but the array type is not defined.",
property.Key);
}

IDictionary<string, OpenApiSchema> propertyList = property.Value.Type == "array"
? property.Value.Items.Properties
: property.Value.Properties;
Expand Down

0 comments on commit db98f61

Please sign in to comment.