diff --git a/lib/dry/schema/extensions/json_schema/schema_compiler.rb b/lib/dry/schema/extensions/json_schema/schema_compiler.rb index 55812be7..275cbbb5 100644 --- a/lib/dry/schema/extensions/json_schema/schema_compiler.rb +++ b/lib/dry/schema/extensions/json_schema/schema_compiler.rb @@ -90,7 +90,7 @@ def visit(node, opts = EMPTY_HASH) def visit_set(node, opts = EMPTY_HASH) target = (key = opts[:key]) ? self.class.new(loose: loose?) : self - node.map { |child| target.visit(child, opts) } + node.map { |child| target.visit(child, opts.except(:member)) } return unless key diff --git a/spec/extensions/json_schema/schema_spec.rb b/spec/extensions/json_schema/schema_spec.rb index b717631a..c766aba6 100644 --- a/spec/extensions/json_schema/schema_spec.rb +++ b/spec/extensions/json_schema/schema_spec.rb @@ -27,6 +27,10 @@ required(:roles).array(:hash) do required(:name).value(:string, min_size?: 12, max_size?: 36) + + required(:metadata).hash do + required(:assigned_at).value(:time) + end end optional(:address).hash do @@ -59,9 +63,19 @@ type: "string", minLength: 12, maxLength: 36 + }, + metadata: { + type: "object", + properties: { + assigned_at: { + format: "time", + type: "string" + } + }, + required: %w[assigned_at] } }, - required: ["name"] + required: %w[name metadata] } }, address: {