Sha256: 5bba0939903ed49f68ca76d58fbd109def1740d11b80a663f1ab20baf331481e
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 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 schemas.include?(@path) ? [] : [@path] end protected def init @path = options.delete(:path) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems