Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on additional parameters? #2358

Closed
timjnh opened this issue Oct 18, 2023 · 1 comment
Closed

Error on additional parameters? #2358

timjnh opened this issue Oct 18, 2023 · 1 comment

Comments

@timjnh
Copy link

timjnh commented Oct 18, 2023

Are there any options to trigger error responses if extra parameters are provided? I'd like to get errors by default if a caller provides fields beyond my specification. I understand that I can strip them with declared but I want to tell people when they're calling my API incorrectly and I'd prefer not to have to write boilerplate to compare params and declared(params) for every route.

To be clear, I'm looking for this configuration:

params do
  requires :user, type: Hash do
    requires :name, type: String
  end
end

to return a 400 if I provide the following JSON:

{ "user": { "name": "me", "other_field": "bleh" } }
@dblock
Copy link
Member

dblock commented Oct 19, 2023

This is a dup of #810, so I am going to close it, but this is a great feature! Would love to see someone contribute a solution for it. There are some ideas in that issue about how this could be implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants