class Swaggard::Swagger::ResponseHeader
Attributes
name[R]
Public Class Methods
new(string)
click to toggle source
# File lib/swaggard/swagger/response_header.rb, line 6 def initialize(string) parse(string) end
Public Instance Methods
to_doc()
click to toggle source
# File lib/swaggard/swagger/response_header.rb, line 10 def to_doc { 'description' => @description, 'type' => @type, } end
Private Instance Methods
parse(string)
click to toggle source
Example: [Array] status Filter by status. (e.g. status[]=1&status=2&status[]=3) Example: [Array]! status Filter by status. (e.g. status[]=1&status=2&status[]=3) Example: [Integer] media ID of the desired media type.
# File lib/swaggard/swagger/response_header.rb, line 22 def parse(string) data_type, name, options_and_description = string.match(/\A\[(\S*)\]\s*([\w\-\[\]]*)\s*(.*)\Z/).captures allow_multiple = name.gsub!('[]', '') options, description = options_and_description.match(/\A(\[.*\])?(.*)\Z/).captures options = options ? options.gsub(/\[?\]?\s?/, '').split(',') : [] @name = name @description = description @type = data_type @allow_multiple = allow_multiple.present? @options = options end