Class: R2OAS::Schema::V3::FromFiles::PathItemObject

Inherits:
BaseObject show all
Includes:
Callable, DeepMethods
Defined in:
lib/r2-oas/schema/v3/object/from_files/path_item_object.rb

Instance Method Summary collapse

Methods included from DeepMethods

#deep_replace!

Methods included from Callable

#deep_call

Methods inherited from BaseObject

obj_store

Constructor Details

#initialize(doc, ref, opts = {}) ⇒ PathItemObject

Returns a new instance of PathItemObject.



17
18
19
20
21
22
# File 'lib/r2-oas/schema/v3/object/from_files/path_item_object.rb', line 17

def initialize(doc, ref, opts = {})
  super(opts)
  @doc = doc
  @parent_ref = PathRef.new(ref)
  resolve_dependencies!
end

Instance Method Details

#call_ref_path!Object



46
47
48
49
# File 'lib/r2-oas/schema/v3/object/from_files/path_item_object.rb', line 46

def call_ref_path!
  callback = proc { |obj| obj.ref_path }
  deep_call(@doc, '$ref', callback)
end

#resolve_dependencies!Object

Breaking changes to @doc



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/r2-oas/schema/v3/object/from_files/path_item_object.rb', line 34

def resolve_dependencies!
  local_ref_hash = ref_dup.to_h

  @doc.each do |verb, data_when_verb|
    local_ref_hash[:verb] = verb
    local_ref_hash[:tag_name] = data_when_verb['tags'].first

    resolve_dependencies_at_schema!(@doc, verb, data_when_verb, local_ref_hash)
    resolve_dependencies_at_request_body!(@doc, verb, data_when_verb, local_ref_hash)
  end
end

#to_docObject



24
25
26
27
28
29
30
31
# File 'lib/r2-oas/schema/v3/object/from_files/path_item_object.rb', line 24

def to_doc
  call_ref_path!

  # MEMO:
  # If it is overwritten, it may lead to unexpected problems, so give a copy
  execute_transform_plugins(:path_item, @doc, ref_dup)
  @doc
end