From b5690f47e2d8fad7150bb47717f0c20085b551fe Mon Sep 17 00:00:00 2001 From: Nicholas Tsim Date: Fri, 6 Sep 2024 18:14:30 +0100 Subject: [PATCH] EES-5494 Fix examples unable to render when no type provided --- lib/api_reference_helpers.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/api_reference_helpers.rb b/lib/api_reference_helpers.rb index b115118..478f091 100644 --- a/lib/api_reference_helpers.rb +++ b/lib/api_reference_helpers.rb @@ -30,7 +30,7 @@ def schema_example(schema_data, references = []) schema_example(schema) when "array" if schema.items && schema.items != schema_data - unless schema.items.one_of.nil? + if schema.items.one_of schema.items.one_of .reject { |item| references.include?(item) } .map { |item| schema_example(item, references + [item]) } @@ -40,6 +40,13 @@ def schema_example(schema_data, references = []) else [] end + when nil + # Schema may be using `allOf` to inherit properties + if schema.all_of + schema_example(schema) + else + {} + end else Utils::primitive_schema_example(schema) end @@ -109,7 +116,7 @@ def render_schema_type(schema) "array (#{render_schema_type(items)})" end else - schema.type || "" + schema.type || "any" end end