class APIGatewayDSL::Template
Attributes
content_type[R]
description[R]
schema[R]
Public Class Methods
new(context, **options)
click to toggle source
# File lib/api_gateway_dsl/template.rb, line 11 def initialize(context, **options) @context = context @schema = options[:schema] || @context.default_body_file @velocity = options[:velocity] || @context.default_body_file @description = options[:description].try(:strip_heredoc) @content_type = options[:content_type] || 'application/json' end
new_if_schema_present(context, **options)
click to toggle source
# File lib/api_gateway_dsl/template.rb, line 6 def self.new_if_schema_present(context, **options) template = new(context, **options) template.schema_value ? template : nil end
Public Instance Methods
as_json()
click to toggle source
# File lib/api_gateway_dsl/template.rb, line 21 def as_json current_dir.join("#{@velocity}.vtl").read end
parameter()
click to toggle source
# File lib/api_gateway_dsl/template.rb, line 35 def parameter Parameter::Body.new(self) end
schema_value()
click to toggle source
# File lib/api_gateway_dsl/template.rb, line 25 def schema_value return unless current_dir if (file = current_dir.join("#{@schema}.json")).exist? JSON.parse(file.read) elsif (file = current_dir.join("#{@schema}.yml")).exist? YAML.safe_load(file.read) end end
Private Instance Methods
current_dir()
click to toggle source
# File lib/api_gateway_dsl/template.rb, line 41 def current_dir @context.current_dir end