Class: SoberSwag::Reporting::Input::Object::Property
- Inherits:
-
Object
- Object
- SoberSwag::Reporting::Input::Object::Property
- Defined in:
- lib/sober_swag/reporting/input/object/property.rb
Overview
Describe a single property key in an object.
Instance Attribute Summary collapse
-
#description ⇒ String?
readonly
Description.
-
#value ⇒ SoberSwag::Reporting::Input::Interface
readonly
Value type.
Instance Method Summary collapse
- #add_description(dir) ⇒ Object private
-
#initialize(value, required:, description: '') ⇒ Property
constructor
A new instance of Property.
- #property_schema ⇒ Object
- #required? ⇒ Boolean
Constructor Details
#initialize(value, required:, description: '') ⇒ Property
Returns a new instance of Property.
8 9 10 11 12 |
# File 'lib/sober_swag/reporting/input/object/property.rb', line 8 def initialize(value, required:, description: '') @value = value @required = required @description = description end |
Instance Attribute Details
#description ⇒ String? (readonly)
Returns description.
24 25 26 |
# File 'lib/sober_swag/reporting/input/object/property.rb', line 24 def description @description end |
#value ⇒ SoberSwag::Reporting::Input::Interface (readonly)
Returns value type.
16 17 18 |
# File 'lib/sober_swag/reporting/input/object/property.rb', line 16 def value @value end |
Instance Method Details
#add_description(dir) ⇒ Object (private)
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sober_swag/reporting/input/object/property.rb', line 38 def add_description(dir) t = if dir.key?(:$ref) # workaround: we have to do this if we want to allow # descriptions in reference types { allOf: [dir] } else dir end t.merge(description: description) end |
#property_schema ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/sober_swag/reporting/input/object/property.rb', line 26 def property_schema direct, refined = value.swagger_schema if description [add_description(direct), refined] else [direct, refined] end end |
#required? ⇒ Boolean
18 19 20 |
# File 'lib/sober_swag/reporting/input/object/property.rb', line 18 def required? @required end |