Class: Webspicy::Web::Openapi::DataStruct

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

Constant Summary collapse

MERGER =
Support::DeepMerge.new({
  uniq_on_arrays: true
})

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDataStruct

Returns a new instance of DataStruct.



10
11
12
13
14
# File 'lib/webspicy/web/openapi/data_struct.rb', line 10

def initialize
  @info = {}
  @tags = []
  @paths = {}
end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.



15
16
17
# File 'lib/webspicy/web/openapi/data_struct.rb', line 15

def info
  @info
end

#pathsObject (readonly)

Returns the value of attribute paths.



15
16
17
# File 'lib/webspicy/web/openapi/data_struct.rb', line 15

def paths
  @paths
end

#tagsObject (readonly)

Returns the value of attribute tags.



15
16
17
# File 'lib/webspicy/web/openapi/data_struct.rb', line 15

def tags
  @tags
end

Instance Method Details

#ensure_path(path) ⇒ Object



21
22
23
24
25
26
# File 'lib/webspicy/web/openapi/data_struct.rb', line 21

def ensure_path(path)
  @paths = MERGER.deep_merge(
    @paths,
    path,
  )
end

#ensure_tags(tags) ⇒ Object



17
18
19
# File 'lib/webspicy/web/openapi/data_struct.rb', line 17

def ensure_tags(tags)
  @tags = (@tags + tags).uniq
end

#to_openapi_dataObject



28
29
30
31
32
33
34
35
# File 'lib/webspicy/web/openapi/data_struct.rb', line 28

def to_openapi_data
  {
    "openapi" => '3.0.2',
    "info" => info,
    "tags" => tags,
    "paths" => paths,
  }
end