Class: Swaggard::Swagger::Property
- Inherits:
-
Object
- Object
- Swaggard::Swagger::Property
- Defined in:
- lib/swaggard/swagger/property.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #deprecated? ⇒ Boolean
-
#initialize(name, type, description = '', required = false, options = [], deprecated = false) ⇒ Property
constructor
A new instance of Property.
- #required? ⇒ Boolean
- #to_doc ⇒ Object
Constructor Details
#initialize(name, type, description = '', required = false, options = [], deprecated = false) ⇒ Property
Returns a new instance of Property.
8 9 10 11 12 13 14 15 |
# File 'lib/swaggard/swagger/property.rb', line 8 def initialize(name, type, description = '', required = false, = [], deprecated = false) @id = name @type = type @description = description @required = required @options = @deprecated = deprecated end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/swaggard/swagger/property.rb', line 6 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/swaggard/swagger/property.rb', line 6 def id @id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/swaggard/swagger/property.rb', line 6 def type @type end |
Instance Method Details
#deprecated? ⇒ Boolean
21 22 23 |
# File 'lib/swaggard/swagger/property.rb', line 21 def deprecated? @deprecated end |
#required? ⇒ Boolean
17 18 19 |
# File 'lib/swaggard/swagger/property.rb', line 17 def required? @required end |
#to_doc ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/swaggard/swagger/property.rb', line 25 def to_doc result = @type.to_doc result['description'] = @description if @description.present? result['enum'] = @options if @options.present? result['deprecated'] = true if @deprecated result end |