class Apipie::Generator::Swagger::ParamDescription::In

Constants

IN_KEYWORD_DEFAULT_VALUES

Public Class Methods

new(param_description, in_schema:, default_in_value:, http_method:) click to toggle source
# File lib/apipie/generator/swagger/param_description/in.rb, line 7
def initialize(param_description, in_schema:, default_in_value:, http_method:)
  @param_description = param_description
  @in_schema = in_schema
  @default_in_value = default_in_value
  @http_method = http_method
end

Public Instance Methods

to_hash() click to toggle source

@return [Hash]

# File lib/apipie/generator/swagger/param_description/in.rb, line 15
def to_hash
  # The "name" and "in" keys can only be set on root parameters (non-nested)
  return {} if @in_schema

  { in: in_value }
end

Private Instance Methods

body_allowed_for_current_method?() click to toggle source
# File lib/apipie/generator/swagger/param_description/in.rb, line 34
def body_allowed_for_current_method?
  %w[get head].exclude?(@http_method)
end
in_value() click to toggle source
# File lib/apipie/generator/swagger/param_description/in.rb, line 24
def in_value
  return @default_in_value if @default_in_value.present?

  if body_allowed_for_current_method?
    IN_KEYWORD_DEFAULT_VALUES[:form_data]
  else
    IN_KEYWORD_DEFAULT_VALUES[:query]
  end
end