Sha256: a31150016202b8196178f6beb35fd4ecb0ad37e5a74e1a4cd64cdd11891173a0

Contents?: true

Size: 1.68 KB

Versions: 40

Compression:

Stored size: 1.68 KB

Contents

class OpenAPIParser::SchemaLoader
end

require_relative './schema_loader/base'
require_relative './schema_loader/creator'
require_relative './schema_loader/values_loader'
require_relative './schema_loader/list_loader'
require_relative './schema_loader/objects_loader'
require_relative './schema_loader/hash_objects_loader'
require_relative './schema_loader/hash_body_loader'

# load data to target_object by schema definition in core
class OpenAPIParser::SchemaLoader
  # @param [OpenAPIParser::Schemas::Base] target_object
  # @param [OpenAPIParser::Parser::Core] core
  def initialize(target_object, core)
    @target_object = target_object
    @core = core
    @children = {}
  end

  # @!attribute [r] children
  #   @return [Array<OpenAPIParser::Schemas::Base>]
  attr_reader :children

  # execute load data
  # return data is equal to :children
  # @return [Array<OpenAPIParser::Schemas::Base>]
  def load_data
    all_loader.each { |l| load_data_by_schema_loader(l) }
    children
  end

  private

    attr_reader :core, :target_object

    # @param [OpenAPIParser::SchemaLoader::Base] schema_loader
    def load_data_by_schema_loader(schema_loader)
      children = schema_loader.load_data(target_object, target_object.raw_schema)

      children.each { |c| register_child(c) } if children
    end

    def register_child(object)
      return unless object.kind_of?(OpenAPIParser::Parser)

      @children[object.object_reference] = object
    end

    def all_loader
      core._openapi_attr_values.values +
        core._openapi_attr_objects.values +
        core._openapi_attr_list_objects.values +
        core._openapi_attr_hash_objects.values +
        core._openapi_attr_hash_body_objects.values
    end
end

Version data entries

40 entries across 40 versions & 2 rubygems

Version Path
openapi_parser-2.2.2 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-2.2.1 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-2.2.0 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-2.1.0 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-2.0.0 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser_firetail-1.0.0 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-1.0.0 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-1.0.0.beta1 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-0.15.0 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-0.14.1 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-0.14.0 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-0.13.0 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-0.12.1 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-0.12.0 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-0.11.2 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-0.11.1 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-0.11.0 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-0.10.0 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-0.9.0 lib/openapi_parser/concerns/schema_loader.rb
openapi_parser-0.8.0 lib/openapi_parser/concerns/schema_loader.rb