Sha256: 61455fb71ff83abb661615b6940d63bd0ae4406c771d37c3bc03868b66adc836

Contents?: true

Size: 1.15 KB

Versions: 20

Compression:

Stored size: 1.15 KB

Contents

require 'active_support/concern'

module Grape
  module DSL
    module Validations
      extend ActiveSupport::Concern

      include Grape::DSL::Configuration

      module ClassMethods
        # Clears all defined parameters and validations.
        def reset_validations!
          unset_namespace_stackable :declared_params
          unset_namespace_stackable :validations
          unset_namespace_stackable :params
          unset_description_field :params
        end

        # Opens a root-level ParamsScope, defining parameter coercions and
        # validations for the endpoint.
        # @yield instance context of the new scope
        def params(&block)
          Grape::Validations::ParamsScope.new(api: self, type: Hash, &block)
        end

        def document_attribute(names, opts)
          setting = description_field(:params)
          setting ||= description_field(:params, {})
          Array(names).each do |name|
            setting[name[:full_name].to_s] ||= {}
            setting[name[:full_name].to_s].merge!(opts)

            namespace_stackable(:params, name[:full_name].to_s => opts)
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
grape-1.2.4 lib/grape/dsl/validations.rb
grape-1.2.3 lib/grape/dsl/validations.rb
grape-1.2.2 lib/grape/dsl/validations.rb
grape-1.2.1 lib/grape/dsl/validations.rb
grape-1.2.0 lib/grape/dsl/validations.rb
grape-1.1.0 lib/grape/dsl/validations.rb
grape-1.0.3 lib/grape/dsl/validations.rb
grape-1.0.2 lib/grape/dsl/validations.rb
grape-1.0.1 lib/grape/dsl/validations.rb
grape-1.0.0 lib/grape/dsl/validations.rb
grape-0.19.2 lib/grape/dsl/validations.rb
grape-0.19.1 lib/grape/dsl/validations.rb
grape-0.19.0 lib/grape/dsl/validations.rb
grape-0.18.0 lib/grape/dsl/validations.rb
grape-0.17.0 lib/grape/dsl/validations.rb
grape-0.16.2 lib/grape/dsl/validations.rb
grape-0.16.1 lib/grape/dsl/validations.rb
grape-0.15.0 lib/grape/dsl/validations.rb
grape-0.14.0 lib/grape/dsl/validations.rb
grape-0.13.0 lib/grape/dsl/validations.rb