grape-swagger: Uncaught TypeError: Cannot read property '$ref' of undefined

This happens when I make params like this:

  params do
       requires :participants, type: Array do
          use :participant
        end
  end

When I define param as simple Array and write paramas inside of it.

This is most likely bug of Swagger itself, but is it possible to avoid it?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I think there is a similar problem with entities too

 expose :array_attr, documentation:
                {
                  type: 'Array',
                  desc: 'Returns array'
                }

This throws the same error on the swagger-ui:

Uncaught TypeError: Cannot read property '$ref' of undefined

When i validated generated JSON, It seems to be missing required property items. Or is there something i am missing? The responded array would be of string (['string1', 'string2'])

So it should be generating the YAML as:

array_attr: 
    type: "array"
    items:
        type: string

We need something like this to generate the YAML:

 expose :array_attr, documentation:
                {
                  type: 'Array',
                  desc: 'Returns array',
                  item_type: 'String'
                }