Skip to content

Commit

Permalink
Fix for non-Hash arrays (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
newstler authored Nov 2, 2023
1 parent f1fcbf8 commit 9cd2615
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/jbuilder/schema/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ def array!(collection = [], *args, schema: nil, **options, &block)
# Better would be not to set it if it's not needed, but I couldn't figure how,
# as we have array of separate object partials hare, so each one of them would legally have allOf key.
items = _scope { super(collection, *args, &block) }
items = items[:allOf].first if items.key?(:allOf)
items = _object(items, _required!(items.keys)) unless items.key?(:$ref) || items.key?(:object)
if items.is_a?(::Hash)
items = items[:allOf].first if items.key?(:allOf)
items = _object(items, _required!(items.keys)) unless items.key?(:$ref) || items.key?(:object)
end
_attributes.merge! type: :array, items: items
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/jbuilder/schema/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# We can't use the standard `Jbuilder::Schema::VERSION =` because
# `Jbuilder` isn't a regular module namespace, but a class …which also loads Active Support.
# So we use trickery, and assign the proper version once `jbuilder/schema.rb` is loaded.
JBUILDER_SCHEMA_VERSION = "2.6.1"
JBUILDER_SCHEMA_VERSION = "2.6.2"

0 comments on commit 9cd2615

Please sign in to comment.