Skip to content

Commit

Permalink
EES-5494 Fix schema type not considering allOf during fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsim committed Sep 8, 2024
1 parent b5690f4 commit 368e5d3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/api_reference_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def schema_example(schema_data, references = [])
return items ? [schema_example(items)] : []
end

if schema_data.one_of
if schema_data.one_of&.any?
return schema_example(schema_data.one_of[0])
end

Expand Down Expand Up @@ -78,7 +78,7 @@ def get_schema_properties(schema)
# @param [Openapi3Parser::Node::Schema] schema
# @return [String]
def render_schema_type(schema)
unless schema.one_of.nil?
if schema.one_of&.any?
schemas = schema.one_of.map { |s| "<li>#{render_schema_type(s)}</li>" }
.join

Expand Down Expand Up @@ -116,6 +116,12 @@ def render_schema_type(schema)
"array (#{render_schema_type(items)})"
end
else
# Make assumption that all oneOf items are same type as
# Swashbuckle theoretically shouldn't allow different types.
if schema.all_of&.any?
return render_schema_type(schema.all_of[0])
end

schema.type || "any"
end
end
Expand Down

0 comments on commit 368e5d3

Please sign in to comment.