Class: Praxis::Docs::OpenApi::ServerObject

Inherits:
Object
  • Object
show all
Defined in:
lib/praxis/docs/open_api/server_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, description: nil, variables: []) ⇒ ServerObject

Returns a new instance of ServerObject.



10
11
12
13
14
15
# File 'lib/praxis/docs/open_api/server_object.rb', line 10

def initialize(url:, description: nil, variables: [])
  @url = url
  @description = description
  @variables = variables
  raise "OpenApi docs require a 'url' for your server object." unless url
end

Instance Attribute Details

#descriptionObject (readonly)



8
9
10
# File 'lib/praxis/docs/open_api/server_object.rb', line 8

def description
  @description
end

#urlObject (readonly)



8
9
10
# File 'lib/praxis/docs/open_api/server_object.rb', line 8

def url
  @url
end

#variablesObject (readonly)



8
9
10
# File 'lib/praxis/docs/open_api/server_object.rb', line 8

def variables
  @variables
end

Instance Method Details

#dumpObject



17
18
19
20
21
22
23
# File 'lib/praxis/docs/open_api/server_object.rb', line 17

def dump
  result = { url: url }
  result[:description] = description if description
  result[:variables] = variables unless variables.empty?

  result
end