Class: Webspicy::Web::Openapi::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/webspicy/web/openapi/generator.rb

Constant Summary collapse

DEFAULT_OPENAPI =
{
  openapi: '3.0.2',
  info: {
    version: '1.0.0',
    title: 'Webspicy Specification'
  }
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Generator

Returns a new instance of Generator.



16
17
18
19
20
21
# File 'lib/webspicy/web/openapi/generator.rb', line 16

def initialize(config)
  @config = Configuration.dress(config)
  @generator = config.generator || Finitio::Generation.new(
    collection_size: 1..1
  )
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



22
23
24
# File 'lib/webspicy/web/openapi/generator.rb', line 22

def config
  @config
end

#generatorObject (readonly)

Returns the value of attribute generator.



22
23
24
# File 'lib/webspicy/web/openapi/generator.rb', line 22

def generator
  @generator
end

Instance Method Details

#call(info = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/webspicy/web/openapi/generator.rb', line 24

def call(info = {})
  base = Support::DeepMerge.deep_merge(
    DEFAULT_OPENAPI,
    base_openapi
  )
  Support::DeepMerge.deep_merge(
    base,
    {
      info: info,
      tags: tags,
      paths: paths
    }
  )
end