Class: Vigia::Adapters::Raml
Instance Attribute Summary collapse
#source_file, #structure
Instance Method Summary
collapse
instance, #required_payload?, setup_adapter, template, #with_payload?
Instance Attribute Details
#raml ⇒ Object
Returns the value of attribute raml.
5
6
7
|
# File 'lib/vigia/adapters/raml.rb', line 5
def raml
@raml
end
|
Instance Method Details
68
69
70
71
72
73
|
# File 'lib/vigia/adapters/raml.rb', line 68
def (body)
(body.parent.).tap do ||
.merge!(content_type: body.media_type) unless body.parent.name == 204 or .key?(:content_type)
end
end
|
#parameters_for(method) ⇒ Object
55
56
57
|
# File 'lib/vigia/adapters/raml.rb', line 55
def parameters_for(method)
format_parameters(method.query_parameters) + format_parameters(method.parent.uri_parameters)
end
|
#payload_for(method, body) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/vigia/adapters/raml.rb', line 75
def payload_for(method, body)
return unless with_payload?(method.name)
payload = request_body_for(method, body)
case
when required_payload?(method.name) && payload.nil?
raise(
"An example body cannot be found for method #{ method.name } #{ method.parent.resource_path }"
)
when payload.nil?
nil
else
payload.example || payload.schema.value
end
end
|
59
60
61
62
63
64
65
66
|
# File 'lib/vigia/adapters/raml.rb', line 59
def (body)
method = body.parent.parent
(method.).tap do ||
return unless with_payload?(method.name)
return if request_body_for(method, body).name == '*/*'
.merge!(content_type: request_body_for(method, body).name)
end
end
|
#resource_uri_template(method) ⇒ Object
50
51
52
53
|
# File 'lib/vigia/adapters/raml.rb', line 50
def resource_uri_template(method)
uri_template = method.parent.resource_path
uri_template += query_parameters(method)
end
|