Class: R2OAS::Schema::V3::FromFiles::OpenapiObject

Inherits:
BaseObject show all
Defined in:
lib/r2-oas/schema/v3/object/from_files/openapi_object.rb

Instance Method Summary collapse

Methods inherited from BaseObject

obj_store

Constructor Details

#initialize(doc, opts = {}) ⇒ OpenapiObject

Returns a new instance of OpenapiObject.



14
15
16
17
18
19
# File 'lib/r2-oas/schema/v3/object/from_files/openapi_object.rb', line 14

def initialize(doc, opts = {})
  super(opts)
  @doc = doc
  set_root_doc(doc)
  set_components_name_list(doc)
end

Instance Method Details

#to_docObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/r2-oas/schema/v3/object/from_files/openapi_object.rb', line 21

def to_doc
  execute_transform_plugins(:setup)
  # MEMO:
  # Make sure paths_doc is run first
  # This is because the components object is stored in the store by executing paths_doc
  # and it is looped to generate the component document.
  result = {
    'openapi' => '3.0.0',
    'info' => info_doc,
    'tags' => @doc['tags'],
    'paths' => paths_doc,
    'externalDocs' => external_docs_doc,
    'servers' => @doc['servers'],
    'components' => components_doc
  }
  execute_transform_plugins(:teardown)
  result
end