Module: RatPackSwagger::DefinitionClass
- Defined in:
- lib/rat_pack_swagger.rb
Instance Method Summary collapse
-
#definition ⇒ Object
makes sure @definition is initialized.
-
#properties(&block) ⇒ Object
Class declaration API.
- #required(*args) ⇒ Object
- #to_swagger_h ⇒ Object
Instance Method Details
#definition ⇒ Object
makes sure @definition is initialized
11 12 13 14 15 16 17 18 |
# File 'lib/rat_pack_swagger.rb', line 11 def definition @definition ||= { type: 'object', required: [], properties: {} } @definition end |
#properties(&block) ⇒ Object
Class declaration API
25 26 27 28 29 30 31 |
# File 'lib/rat_pack_swagger.rb', line 25 def properties(&block) definition[:properties].merge!(SwaggerObject.new(&block).to_h) # create top-level property accessors for instance-like usage definition[:properties].keys.each do |k| self.send(:attr_accessor, k) end end |
#required(*args) ⇒ Object
32 33 34 |
# File 'lib/rat_pack_swagger.rb', line 32 def required(*args) definition[:required].concat([*args]).uniq! end |
#to_swagger_h ⇒ Object
20 21 22 |
# File 'lib/rat_pack_swagger.rb', line 20 def to_swagger_h definition end |