1

Suppose an endpoint in the api code is defined with the below structure

        resources :endpoint do
          desc 'Fetches all content for this endpoint'
          params do
            optional :attr1, type: Integer
            optional :attr2, type: String
            optional :attr3, type: String
          end

I can use postman or any similar tool to test this endpoint, for ex:

../endpoint?attr1=5&attr2='string' -> 'returns an output that is expected'
../endpoint?attr4='random_string'  -> I expect this to return a 406

How to define above grape endpoint logic to invalidate a certain parameter not defined under optional/required ?

I can define a validation at model level to check for parameters being sent, but I am wondering if its possible for Grape to throw an error for a parameter not listed under required/optional key

MrKickass
  • 93
  • 1
  • 13

0 Answers0