Skip to content

Array of entities in request body #666

Open
@yewton

Description

@yewton

Related issue: ruby-grape/grape-entity#252

As for example above, we want request body to be:

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

But actually:

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

Grape also wants the array to be in the key of top level JSON object.
( Top level array data cannot be handled by Grape out of the box ( cf. ruby-grape/grape#1730 ). )

So it seems the generated specification is broken.

A workaround is to adding dummy optional parameter.
It forces the request body to be a JSON object.

I've found that making MoveParams#build_definition to always use object_type fixes the issue.
Is this reasonable fix?

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