Class: OpenapiRuby::Components::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_ruby/components/loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths: nil, scope: nil) ⇒ Loader

Returns a new instance of Loader.



8
9
10
11
# File 'lib/openapi_ruby/components/loader.rb', line 8

def initialize(paths: nil, scope: nil)
  @paths = paths || OpenapiRuby.configuration.component_paths
  @scope = scope&.to_sym
end

Instance Attribute Details

#pathsObject (readonly)

Returns the value of attribute paths.



6
7
8
# File 'lib/openapi_ruby/components/loader.rb', line 6

def paths
  @paths
end

Instance Method Details

#callbacksObject



57
58
59
# File 'lib/openapi_ruby/components/loader.rb', line 57

def callbacks
  filter_type(:callbacks)
end

#examplesObject



49
50
51
# File 'lib/openapi_ruby/components/loader.rb', line 49

def examples
  filter_type(:examples)
end

#headersObject



45
46
47
# File 'lib/openapi_ruby/components/loader.rb', line 45

def headers
  filter_type(:headers)
end


53
54
55
# File 'lib/openapi_ruby/components/loader.rb', line 53

def links
  filter_type(:links)
end

#load!Object



13
14
15
16
17
18
# File 'lib/openapi_ruby/components/loader.rb', line 13

def load!
  define_namespace_modules!
  load_component_files!
  @@loaded = true # rubocop:disable Style/ClassVars
  self
end

#parametersObject



29
30
31
# File 'lib/openapi_ruby/components/loader.rb', line 29

def parameters
  filter_type(:parameters)
end

#request_bodiesObject



37
38
39
# File 'lib/openapi_ruby/components/loader.rb', line 37

def request_bodies
  filter_type(:requestBodies)
end

#responsesObject



41
42
43
# File 'lib/openapi_ruby/components/loader.rb', line 41

def responses
  filter_type(:responses)
end

#schemasObject



25
26
27
# File 'lib/openapi_ruby/components/loader.rb', line 25

def schemas
  filter_type(:schemas)
end

#security_schemesObject



33
34
35
# File 'lib/openapi_ruby/components/loader.rb', line 33

def security_schemes
  filter_type(:securitySchemes)
end

#to_openapi_hashObject



20
21
22
23
# File 'lib/openapi_ruby/components/loader.rb', line 20

def to_openapi_hash
  ensure_loaded!
  Registry.instance.to_openapi_hash(scope: @scope)
end