Class: SoberSwag::Reporting::Output::Object::Property

Inherits:
Object
  • Object
show all
Defined in:
lib/sober_swag/reporting/output/object/property.rb

Overview

Definitions for a specific property of an object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output, description: nil) ⇒ Property

Returns a new instance of Property.



8
9
10
11
# File 'lib/sober_swag/reporting/output/object/property.rb', line 8

def initialize(output, description: nil)
  @output = output
  @description = description
end

Instance Attribute Details

#descriptionString? (readonly)

Returns:

  • (String, nil)


18
19
20
# File 'lib/sober_swag/reporting/output/object/property.rb', line 18

def description
  @description
end

#outputInterface (readonly)

Returns:



14
15
16
# File 'lib/sober_swag/reporting/output/object/property.rb', line 14

def output
  @output
end

Instance Method Details

#add_description(dir) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/sober_swag/reporting/output/object/property.rb', line 34

def add_description(dir)
  if dir.key?(:$ref)
    { allOf: [dir] }
  else
    dir
  end.merge(description: description)
end

#call(item, view: :base) ⇒ Object



20
21
22
# File 'lib/sober_swag/reporting/output/object/property.rb', line 20

def call(item, view: :base)
  output.call(item, view: view)
end

#property_schemaObject



24
25
26
27
28
29
30
31
32
# File 'lib/sober_swag/reporting/output/object/property.rb', line 24

def property_schema
  direct, refined = output.swagger_schema

  if description
    [add_description(direct), refined]
  else
    [direct, refined]
  end
end