Sha256: 59179ab219b25fbd849562d9c40b404871afcf6d37744d3637f386f23ad69e7d
Contents?: true
Size: 1.31 KB
Versions: 23
Compression:
Stored size: 1.31 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 if context.swagger_json? process_json([], '$ref': "#/components/schemas/#{@path}") else process_json([], '$ref': "#/definitions/#{@path}") end 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
23 entries across 23 versions & 1 rubygems