Class: Swaggable::EndpointDefinition
- Inherits:
-
Object
- Object
- Swaggable::EndpointDefinition
- Includes:
- DefinitionBase
- Defined in:
- lib/swaggable/endpoint_definition.rb
Instance Method Summary collapse
- #body ⇒ Object
- #configure(&block) ⇒ Object
- #consumes ⇒ Object
-
#initialize(*args, &block) ⇒ EndpointDefinition
constructor
A new instance of EndpointDefinition.
- #match?(v, p) ⇒ Boolean
- #parameters ⇒ Object
- #path_parameters_for(path) ⇒ Object
- #produces ⇒ Object
- #responses ⇒ Object
- #tags ⇒ Object
- #verb=(value) ⇒ Object
Methods included from DefinitionBase
Constructor Details
#initialize(*args, &block) ⇒ EndpointDefinition
Returns a new instance of EndpointDefinition.
16 17 18 19 |
# File 'lib/swaggable/endpoint_definition.rb', line 16 def initialize *args, &block self.verb = 'GET' super *args, &block end |
Instance Method Details
#body ⇒ Object
67 68 69 |
# File 'lib/swaggable/endpoint_definition.rb', line 67 def body parameters.detect {|p| p.location == :body } end |
#configure(&block) ⇒ Object
50 51 52 53 |
# File 'lib/swaggable/endpoint_definition.rb', line 50 def configure &block ForwardingDsl.run(self, &block) self end |
#consumes ⇒ Object
42 43 44 |
# File 'lib/swaggable/endpoint_definition.rb', line 42 def consumes @consumes ||= MimeTypesCollection.new end |
#match?(v, p) ⇒ Boolean
55 56 57 |
# File 'lib/swaggable/endpoint_definition.rb', line 55 def match? v, p v.to_s.upcase == verb.to_s.upcase && !!(path_template.match p) end |
#parameters ⇒ Object
28 29 30 31 32 33 |
# File 'lib/swaggable/endpoint_definition.rb', line 28 def parameters @parameters ||= MiniObject::IndexedList.new.tap do |l| l.build { ParameterDefinition.new } l.key {|e| e.name } end end |
#path_parameters_for(path) ⇒ Object
63 64 65 |
# File 'lib/swaggable/endpoint_definition.rb', line 63 def path_parameters_for path path_template.extract(path) || {} end |
#produces ⇒ Object
46 47 48 |
# File 'lib/swaggable/endpoint_definition.rb', line 46 def produces @produces ||= MimeTypesCollection.new end |
#responses ⇒ Object
35 36 37 38 39 40 |
# File 'lib/swaggable/endpoint_definition.rb', line 35 def responses @responses ||= MiniObject::IndexedList.new.tap do |l| l.build { ResponseDefinition.new } l.key {|e| e.status } end end |
#tags ⇒ Object
21 22 23 24 25 26 |
# File 'lib/swaggable/endpoint_definition.rb', line 21 def @tags ||= MiniObject::IndexedList.new.tap do |l| l.build { TagDefinition.new } l.key {|e| e.name } end end |
#verb=(value) ⇒ Object
59 60 61 |
# File 'lib/swaggable/endpoint_definition.rb', line 59 def verb= value @verb = value.to_s.upcase end |