Usage: # ... params do optional :shelf_id, type: Integer given :shelf_id do requires :bin_id, type: Integer end end This implements #958. In order to achieve the DSL-style implementation, I introduced the concept of a "lateral scope" as opposed to the "nested scope" which `requires :foo do` opens up. A lateral scope is subordinate to its parent, but not nested under an element.
While using https://github.com/aserafin/grape_logging grape middleware after an upgrading grape from 0.11 to 0.12 I've been stuck with an issue: ``` NoMethodError (undefined method `downcase' for 2:Fixnum) ``` That's because `Middleware#response` tries to convert `Rack::Response` to `Rack::Response` and fails.
Increases YARD coverage from ~37% to ~50%. This is a long journey! Also, fixes YARD warnings.
Any class can now be used as a type for a parameter, so long as it defines a class-level `parse` method. This method should raise on invalid values and otherwise return the coerced value. Also, I added the Grape::ParameterTypes module, which serves right now only as a basis to determine if a given type is a custom type or not, but in the future could be used to actually validate the types that are given via the params DSL.
Rubinius will raise a TypeError, should you try String.dup, whereas MRI has no problem with it. As such, this change marks String as un- duplicable with respect to ActiveSupports' #duplicable? method, used by #deep_dup. Since this change isn't in upstream ActiveSupport, I also forced the backport to always be loaded (this could be changed to just a monkeypatch of the String class, though).