Module: Grape::DSL::Validations::ClassMethods
- Defined in:
- lib/grape/dsl/validations.rb
Instance Method Summary collapse
- #document_attribute(names, opts) ⇒ Object
-
#params { ... } ⇒ Object
Opens a root-level ParamsScope, defining parameter coercions and validations for the endpoint.
-
#reset_validations! ⇒ Object
Clears all defined parameters and validations.
Instance Method Details
#document_attribute(names, opts) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/grape/dsl/validations.rb', line 26 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 |
#params { ... } ⇒ Object
Opens a root-level ParamsScope, defining parameter coercions and validations for the endpoint.
22 23 24 |
# File 'lib/grape/dsl/validations.rb', line 22 def params(&block) Grape::Validations::ParamsScope.new(api: self, type: Hash, &block) end |
#reset_validations! ⇒ Object
Clears all defined parameters and validations.
12 13 14 15 16 17 |
# File 'lib/grape/dsl/validations.rb', line 12 def reset_validations! unset_namespace_stackable :declared_params unset_namespace_stackable :validations unset_namespace_stackable :params unset_description_field :params end |