class Swagger::Docs::SwaggerModelDSL
Attributes
id[RW]
Public Class Methods
call(model_name, caller, &block)
click to toggle source
# File lib/swagger/docs/dsl.rb, line 79 def self.call(model_name, caller, &block) # Create a new SwaggerModelDSL instance, and instance_eval the block to it instance = new instance.instance_eval(&block) instance.id = model_name # Now return all of the set instance variables as a Hash instance.instance_variables.inject({}) { |result_hash, instance_var_name| key = instance_var_name[1..-1].to_sym # Strip prefixed @ sign. result_hash[key] = instance.instance_variable_get(instance_var_name) result_hash # Gotta have the block return the result_hash } end
Public Instance Methods
description(description)
click to toggle source
# File lib/swagger/docs/dsl.rb, line 100 def description(description) @description = description end
properties()
click to toggle source
# File lib/swagger/docs/dsl.rb, line 92 def properties @properties ||= {} end
property(name, type, required, description = nil, hash={})
click to toggle source
# File lib/swagger/docs/dsl.rb, line 104 def property(name, type, required, description = nil, hash={}) properties[name] = { type: type, description: description, }.merge!(hash) self.required << name if required == :required end
property_list(name, type, required, description = nil, allowed_values = [], hash = {})
click to toggle source
helper method to generate enums
# File lib/swagger/docs/dsl.rb, line 113 def property_list(name, type, required, description = nil, allowed_values = [], hash = {}) hash.merge!({allowable_values: {value_type: "LIST", values: allowed_values}}) property(name, type, required, description, hash) end
required()
click to toggle source
# File lib/swagger/docs/dsl.rb, line 96 def required @required ||= [] end