Class: OpenApi::Info

Inherits:
Object
  • Object
show all
Includes:
EquatableAsContent
Defined in:
lib/open_api/info.rb

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EquatableAsContent

#==

Constructor Details

#initialize(title:, description: nil, terms_of_service: nil, contact: nil, license: nil, version:) ⇒ Info

Returns a new instance of Info.



8
9
10
11
12
13
14
15
# File 'lib/open_api/info.rb', line 8

def initialize(title:, description: nil, terms_of_service: nil, contact: nil, license: nil, version:)
  self.title = title
  self.description = description
  self.terms_of_service = terms_of_service
  self.contact = contact
  self.license = license
  self.version = version
end

Instance Attribute Details

#contactObject

Returns the value of attribute contact.



6
7
8
# File 'lib/open_api/info.rb', line 6

def contact
  @contact
end

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/open_api/info.rb', line 6

def description
  @description
end

#licenseObject

Returns the value of attribute license.



6
7
8
# File 'lib/open_api/info.rb', line 6

def license
  @license
end

#terms_of_serviceObject

Returns the value of attribute terms_of_service.



6
7
8
# File 'lib/open_api/info.rb', line 6

def terms_of_service
  @terms_of_service
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/open_api/info.rb', line 6

def title
  @title
end

#versionObject

Returns the value of attribute version.



6
7
8
# File 'lib/open_api/info.rb', line 6

def version
  @version
end

Class Method Details

.load(hash) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/open_api/info.rb', line 28

def self.load(hash)
  new(
    title: hash["title"].to_s,
    description: hash["description"]&.to_s,
    terms_of_service: hash["termsOfService"]&.to_s,
    contact: Contact.load(hash["contact"]),
    license: License.load(hash["license"]),
    version: hash["version"].to_s,
  )
end

Instance Method Details

#serializable_hashObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/open_api/info.rb', line 17

def serializable_hash
  {
    "title" => title.to_s,
    "description" => description&.to_s,
    "termsOfService" => terms_of_service&.to_s,
    "contact" => contact&.serializable_hash,
    "license" => license&.serializable_hash,
    "version" => version.to_s,
  }.compact
end