Sha256: 52533f8e5a4d644b35361c1a12e9fd2b1f2ab4c2963b482a9c290ac8f1823dd0
Contents?: true
Size: 1.19 KB
Versions: 9
Compression:
Stored size: 1.19 KB
Contents
module Schemacop module V3 class ReferenceNode < Node def self.allowed_options super + %i[path] end def self.create(path, **options, &block) options[:path] = path super(**options, &block) end def as_json process_json([], '$ref': "#/definitions/#{@path}") end def _validate(data, result:) super_data = super return if super_data.nil? # Lookup schema # node = target fail "Schema #{@path.to_s.inspect} not found." unless node # Validate schema # node._validate(super_data, result: result) end def target schemas[@path] || Schemacop.context.schemas[@path] || GlobalContext.schema_for(@path) end def cast(data) data = default if data.nil? return target.cast(data) end def used_external_schemas target_children_schema = target.used_external_schemas if schemas.include?(@path) return target_children_schema else return [@path] + target_children_schema end end protected def init @path = options.delete(:path) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems