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

Hash > Hash > Array[Integer] isn't properly reflected in the Data Type column of the UI #74

Open
Crystark opened this issue Feb 10, 2017 · 0 comments
Labels

Comments

@Crystark
Copy link

Hi,

Considering the following resource, It seems to generate an improper swagger Data Type Example Value:

module Test
  module V1
    class Ping < Grape::API
      resource :ping do
        desc "Are you alive!", tags: ['tools']
        params do
          requires :test, type: Hash, documentation: { param_type: 'body' } do
            requires :hash, type: Hash do
              requires :int_array, type: Array[Integer]
            end
          end
        end
        post do
          'pong'
        end
      end
    end
  end
end

This shows the following:

{
  "test": [
    {
      "hash": [
        {
          "int_array": 0
        }
      ]
    }
  ]
}

However I would expect:

{
  "test": {
    "hash": {
      "int_array": [0]
    }
  }
}

The model is also wrong:

postControlPing {
  test (Array[inline_model_11])
}
inline_model_11 {
  hash (Array[Inline Model 1], optional)
}
Inline Model 1 {
  int_array (integer)
}

it should be:

postControlPing {
  test (inline_model_11)
}
inline_model_11 {
  hash (Inline Model 1, optional)
}
Inline Model 1 {
  int_array (Array[integer])
}

It seems like the array breaks it and is set on every parent member instead of the element iteself.

As a quick fix i'm using:

        params do
          requires :test, type: Hash, documentation: { param_type: 'body' } do
            requires :hash, type: Hash do
              requires :int_array, type: Object, documentation: { type: 'Array[Integer]' }
            end
          end
        end

This prints out:

{
  "test": {
    "hash": {}
  }
}

and

postControlPing {
  test (inline_model_11)
}
inline_model_11 {
  hash (Inline Model 1, optional)
}
Inline Model 1 {
  int_array (Array[Integer])
}

The example isn't perfect but i can fix that with a note in the description of the endpoint.
Thanks

@Crystark Crystark changed the title Hash > Hash > Array[Integer] isn't properly reflected in the Data Type Example Value Hash > Hash > Array[Integer] isn't properly reflected in the Data Type column of the UI Feb 10, 2017
@dblock dblock added the bug? label Mar 8, 2017
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