Class: Modern::Descriptor::Parameters::Query

Inherits:
Base
  • Object
show all
Defined in:
lib/modern/descriptor/parameters.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#friendly_name, #openapi3_in, #retrieve

Methods included from Struct::Copy

#copy

Constructor Details

#initialize(fields) ⇒ Query

Returns a new instance of Query.



114
115
116
117
118
# File 'lib/modern/descriptor/parameters.rb', line 114

def initialize(fields)
  super(fields)

  @query_parser = Rack::QueryParser.make_default(99, 99)
end

Instance Attribute Details

#parserObject (readonly)

Returns the value of attribute parser.



112
113
114
# File 'lib/modern/descriptor/parameters.rb', line 112

def parser
  @parser
end

Instance Method Details

#do_retrieve(request, _route_captures = nil) ⇒ Object



120
121
122
# File 'lib/modern/descriptor/parameters.rb', line 120

def do_retrieve(request, _route_captures = nil)
  @query_parser.parse_query(request.query_string)[name]
end

#to_openapi3(is_api_key = false) ⇒ Object



124
125
126
127
128
# File 'lib/modern/descriptor/parameters.rb', line 124

def to_openapi3(is_api_key = false)
  super.merge(
    allowEmptyValue: !is_api_key ? description : nil,
  ).compact
end