class Swagger::Docs::SwaggerDSL
Public Class Methods
call(action, caller, &block)
click to toggle source
# File lib/swagger/docs/dsl.rb, line 5 def self.call(action, caller, &block) # Create a new SwaggerDSL instance, and instance_eval the block to it instance = new instance.instance_eval(&block) # Now return all of the set instance variables as a Hash instance.instance_variables.inject({}) { |result_hash, instance_variable| result_hash[instance_variable] = instance.instance_variable_get(instance_variable) result_hash # Gotta have the block return the result_hash } end
Public Instance Methods
consumes(mime_types)
click to toggle source
# File lib/swagger/docs/dsl.rb, line 36 def consumes(mime_types) @consumes = mime_types end
items(items)
click to toggle source
# File lib/swagger/docs/dsl.rb, line 32 def items(items) @items = items end
method(method)
click to toggle source
# File lib/swagger/docs/dsl.rb, line 24 def method(method) @method = method end
nickname(nickname)
click to toggle source
# File lib/swagger/docs/dsl.rb, line 40 def nickname(nickname) @nickname = nickname end
notes(text)
click to toggle source
# File lib/swagger/docs/dsl.rb, line 20 def notes(text) @notes = text end
param(param_type, name, type, required, description = nil, hash={})
click to toggle source
# File lib/swagger/docs/dsl.rb, line 48 def param(param_type, name, type, required, description = nil, hash={}) parameters << {:param_type => param_type, :name => name, :type => type, :description => description, :required => required == :required}.merge(hash) end
param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})
click to toggle source
helper method to generate enums
# File lib/swagger/docs/dsl.rb, line 54 def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {}) hash.merge!({allowable_values: {value_type: "LIST", values: allowed_values}}) param(param_type, name, type, required, description, hash) end
parameters()
click to toggle source
# File lib/swagger/docs/dsl.rb, line 44 def parameters @parameters ||= [] end
response(status, text = nil, model = nil)
click to toggle source
# File lib/swagger/docs/dsl.rb, line 63 def response(status, text = nil, model = nil) if status.is_a? Symbol status = :ok if status == :success status_code = Rack::Utils.status_code(status) response_messages << {:code => status_code, :responseModel => model, :message => text || status.to_s.titleize} else response_messages << {:code => status, :responseModel => model, :message => text} end response_messages.sort_by!{|i| i[:code]} end
response_messages()
click to toggle source
# File lib/swagger/docs/dsl.rb, line 59 def response_messages @response_messages ||= [] end
summary(text)
click to toggle source
# File lib/swagger/docs/dsl.rb, line 16 def summary(text) @summary = text end
type(type)
click to toggle source
# File lib/swagger/docs/dsl.rb, line 28 def type(type) @type = type end