class WeakSwaggerParameters::Services::WeakParametersOptionsAdapter

Constants

MAX_VALUE
MIN_VALUE

Public Class Methods

adapt(options) click to toggle source
# File lib/weak_swagger_parameters/services/weak_parameters_options_adapter.rb, line 9
def self.adapt(options)
  result = {}
  result[:strong] = true
  result[:required] = options[:required]
  result[:only] = options[:enum] if options[:enum].present?
  result = result.merge(range_options(options))

  result
end
range_options(options) click to toggle source
# File lib/weak_swagger_parameters/services/weak_parameters_options_adapter.rb, line 19
def self.range_options(options)
  return {} unless options.key?(:min) || options.key?(:max)

  max = options[:max] || MAX_VALUE
  min = options[:min] || MIN_VALUE
  { only: min...max }
end