Skip to content

Commit

Permalink
EES-5494 Fix properties in allOf schemas not rendering as required
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsim committed Sep 11, 2024
1 parent fa4d1d5 commit dd656e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions lib/api_reference_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ def render_schema_type(schema)
end
end

# @param [Openapi3Parser::Node::Schema] schema
# @param [Openapi3Parser::Node::Schema, String] property
# @return [Boolean]
def is_required_schema_property?(schema, property)
if schema.requires?(property)
return true
end

if schema.all_of&.any?
return schema.all_of.to_a.reduce(false) do |_, all_of_schema|
all_of_schema.requires?(property)
end
end

false
end

class Utils
# @param [Openapi3Parser::Node::Schema] schema
# @return [String, Number, Boolean]
Expand Down
2 changes: 1 addition & 1 deletion source/schemas/template.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Available options:
<tr>
<td><code class="dfe-word-break--normal"><%= name %></code></td>
<td><%= render_schema_type(property) %></td>
<td><%= schema.requires?(property) %></td>
<td><%= is_required_schema_property?(schema, property) %></td>
<td>
<%= partial("partials/schema_description", :locals => {
description: property.description,
Expand Down

0 comments on commit dd656e5

Please sign in to comment.