Skip to content

declared transforms empty array to hash #1642

Closed
@karhatsu

Description

@karhatsu

I am using 0.19.2 and I have the following endpoint:

        resource :foos do
          params do
            requires :foo, type: Hash do
              requires :name, type: String
              optional :arr, type: Array do
                requires :param1, type: String
                requires :param2, type: String
              end
            end
          end

          post do
            puts "original: #{params.to_hash['foo']}"
            puts "declared: #{declared(params).to_hash['foo']}"
            {}
          end
        end

When I call it with

    {
        foo: {
            name: 'test',
            arr: []
        }
    }

I get this output:

original: {"name"=>"test"}
declared: {"name"=>"test", "arr"=>{"param1"=>nil, "param2"=>nil}}

In other words, for some reason the empty arr array has become a hash containing arr's required fields.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions