Skip to content

is_array: true not compatible with param_type: 'body' #252

Closed
@lumean

Description

@lumean

Hi,
I have the following entities:

module Entity

  class Account < Grape::Entity
    expose :cma, documentation: { type: Integer, desc: 'Company number', param_type: 'body'}
    expose :name, documentation: { type: String, desc: 'Company Name' }
    expose :environment, documentation: { type: String, desc: 'Test Environment' }
    expose :sites, documentation: { type: Integer, desc: 'Amount of sites' }
    expose :username, documentation: { type: String, desc: 'Username for Dashboard' }
    expose :password, documentation: { type: String, desc: 'Password for Dashboard' }
  end
  
  class Accounts < Grape::Entity
    expose :accounts, documentation: { type: Entity::Account, is_array: true, param_type: 'body', required: true } 
  end
  
end # module Entity

and use it as follows in my endpoint:

module Api
  class Accounts < Grape::API
    desc 'createTestAccount',
       params: Entity::Accounts.documentation
    post 'create' do
      JSON(params)
    end
  end
end

But when I generate the swagger documentation for it i still get param_type formData:

grafik

What do I need to change that I get the following JSON in the model / example swagger:

{
  "accounts": [
    {
      "cma": 0,
      "name": "string",
      "environment": "string",
      "sites": 0,
      "username": "string",
      "password": "string"
    }
  ]
}

When I omit is_array: true I'm able to get the proper nesting and param_type body, but of course the array is missing then...
Any suggestions are appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions