Class: SoberSwag::Reporting::Output::Object::Property
- Inherits:
-
Object
- Object
- SoberSwag::Reporting::Output::Object::Property
- Defined in:
- lib/sober_swag/reporting/output/object/property.rb
Overview
Definitions for a specific property of an object.
Instance Attribute Summary collapse
- #description ⇒ String? readonly
- #output ⇒ Interface readonly
Instance Method Summary collapse
- #add_description(dir) ⇒ Object
- #call(item, view: :base) ⇒ Object
-
#initialize(output, description: nil) ⇒ Property
constructor
A new instance of Property.
- #property_schema ⇒ Object
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
#description ⇒ String? (readonly)
18 19 20 |
# File 'lib/sober_swag/reporting/output/object/property.rb', line 18 def description @description end |
#output ⇒ Interface (readonly)
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_schema ⇒ Object
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 |