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

Parameter renaming doesn't work for hash inside given block. #2347

Open
seriousdev-gh opened this issue Aug 22, 2023 · 1 comment
Open

Parameter renaming doesn't work for hash inside given block. #2347

seriousdev-gh opened this issue Aug 22, 2023 · 1 comment
Labels

Comments

@seriousdev-gh
Copy link

Hello, parameter renaming doesn't work if there is a hash inside given.

Params:

requires :A, as: :a, type: Hash do
  requires :category
  given category: ->(val) { val == 'foo' } do
    requires :B, as: :b, type: Hash do
      requires :C, as: :c
    end
  end
end

Input:

{
  "A": {
    "category": "foo",
    "B": {
      "C": "bar"
    },
    "D": "123"
  }
}

After running declared(params, evaluate_given: true):

Expected:

{
  "a": {
    "category": "foo",
    "b": {
      "c": "bar"
    },
    "d": "123"
  }
}

Actual:
Parameters B and C not renamed.

{
  "a": {
    "category": "foo",
    "B": {
      "C": "bar"
    },
    "d": "123"
  }
}

Info: grape version 1.7.1, ruby 3.0.2

@dblock
Copy link
Member

dblock commented Aug 24, 2023

Try turning this into a spec, let's see that it's still the case in the next 1.8?

@dblock dblock added the bug? label Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants