class APIGatewayDSL::Response
Attributes
context[R]
mappings[R]
status_code[R]
templates[R]
Public Class Methods
new(operation, status_code, regexp, &block)
click to toggle source
# File lib/api_gateway_dsl/response.rb, line 6 def initialize(operation, status_code, regexp, &block) @context = operation.context.dup.tap { |c| c.default_body_file = "response/#{status_code}" } @status_code = status_code.to_s @regexp = regexp(regexp) @mappings = Mapping::Collection.new @templates = Template::Collection.new(@context) DSL::ResponseNode.new(self, &block) end
Public Instance Methods
as_json()
click to toggle source
# File lib/api_gateway_dsl/response.rb, line 22 def as_json {}.tap do |result| result[:description] = "#{status_code} response" if (headers = mappings.response_headers.as_json).present? result[:headers] = headers end if (template = templates.current) result[:schema] = template.schema_value end end end
content_types()
click to toggle source
# File lib/api_gateway_dsl/response.rb, line 18 def content_types templates.content_types end
response_integration()
click to toggle source
# File lib/api_gateway_dsl/response.rb, line 36 def response_integration ResponseIntegration.new(@regexp, status_code, mappings, templates) end
Private Instance Methods
regexp(value)
click to toggle source
# File lib/api_gateway_dsl/response.rb, line 42 def regexp(value) case value when NilClass then 'default' when Regexp then value.source else value end end