Module: Grape::DSL::Validations
- Included in:
- API::Instance
- Defined in:
- lib/grape/dsl/validations.rb
Instance Method Summary collapse
-
#contract(contract = nil) { ... } ⇒ Object
Declare the contract to be used for the endpoint’s parameters.
-
#params { ... } ⇒ Object
Opens a root-level ParamsScope, defining parameter coercions and validations for the endpoint.
Instance Method Details
#contract(contract = nil) { ... } ⇒ Object
Declare the contract to be used for the endpoint’s parameters.
19 20 21 22 23 24 |
# File 'lib/grape/dsl/validations.rb', line 19 def contract(contract = nil, &block) raise ArgumentError, 'Either contract or block must be provided' unless contract || block raise ArgumentError, 'Cannot inherit from contract, only schema' if block && contract.respond_to?(:schema) Grape::Validations::ContractScope.new(self, contract, &block) end |
#params { ... } ⇒ Object
Opens a root-level ParamsScope, defining parameter coercions and validations for the endpoint.
9 10 11 |
# File 'lib/grape/dsl/validations.rb', line 9 def params(&) Grape::Validations::ParamsScope.new(api: self, type: Hash, &) end |