Class: Components
- Inherits:
-
Object
- Object
- Components
- Defined in:
- lib/tiki/components.rb
Instance Method Summary collapse
- #array(name, items_type = nil, title = nil, ref: nil, **named, &block) ⇒ Object
- #hash_map(name, items_type = nil, title = nil, ref: nil, **named, &block) ⇒ Object
- #object(name, title = nil, **named, &block) ⇒ Object
-
#parameter(name = nil, ref: nil, **named, &block) ⇒ Object
Parameter.
-
#response(name = nil, _description = nil, ref: nil, **named, &block) ⇒ Object
Response.
-
#schema(name, type = nil, title = nil, **named, &block) ⇒ Object
Schema.
- #to_spec ⇒ Object
Instance Method Details
#array(name, items_type = nil, title = nil, ref: nil, **named, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tiki/components.rb', line 23 def array(name, items_type = nil, title = nil, ref: nil, **named, &block) if ref schema :array, title do items ref: ref end else schema name, :array, title do items items_type, **named, &block end end end |
#hash_map(name, items_type = nil, title = nil, ref: nil, **named, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tiki/components.rb', line 35 def hash_map(name, items_type = nil, title = nil, ref: nil, **named, &block) if ref schema :object, title do additional_properties ref: ref end else schema name, :object, title do additional_properties items_type, **named, &block end end end |
#object(name, title = nil, **named, &block) ⇒ Object
19 20 21 |
# File 'lib/tiki/components.rb', line 19 def object(name, title = nil, **named, &block) schema name, :object, title, **named, &block end |
#parameter(name = nil, ref: nil, **named, &block) ⇒ Object
Parameter
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/tiki/components.rb', line 61 def parameter(name = nil, ref: nil, **named, &block) @parameters ||= [] if ref reference = Reference.new ref @parameters << [name, reference] else parameter = Parameter.new name, **named parameter.instance_eval(&block) if block @parameters << [name, parameter] end end |
#response(name = nil, _description = nil, ref: nil, **named, &block) ⇒ Object
Response
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/tiki/components.rb', line 48 def response(name = nil, _description = nil, ref: nil, **named, &block) if ref reference = Reference.new ref @responses << [name, reference] else @responses ||= [] response = Response.new description, **named response.instance_eval(&block) if block @responses << [name, response] end end |
#schema(name, type = nil, title = nil, **named, &block) ⇒ Object
Schema
12 13 14 15 16 17 |
# File 'lib/tiki/components.rb', line 12 def schema(name, type = nil, title = nil, **named, &block) @schemas ||= [] schema = Schema.new type, title, **named schema.instance_eval(&block) if block @schemas.push [name, schema] end |
#to_spec ⇒ Object
73 74 75 |
# File 'lib/tiki/components.rb', line 73 def to_spec hash_props end |