Class: Swaggable::EndpointDefinition

Inherits:
Object
  • Object
show all
Includes:
DefinitionBase
Defined in:
lib/swaggable/endpoint_definition.rb

Instance Method Summary collapse

Methods included from DefinitionBase

included

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

#bodyObject



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

#consumesObject



42
43
44
# File 'lib/swaggable/endpoint_definition.rb', line 42

def consumes
  @consumes ||= MimeTypesCollection.new
end

#match?(v, p) ⇒ Boolean

Returns:

  • (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

#parametersObject



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

#producesObject



46
47
48
# File 'lib/swaggable/endpoint_definition.rb', line 46

def produces
  @produces ||= MimeTypesCollection.new
end

#responsesObject



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

#tagsObject



21
22
23
24
25
26
# File 'lib/swaggable/endpoint_definition.rb', line 21

def tags
  @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