Array of entities in request body

Abierto
#666 9 comentarios 3 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
ruby
Área
api

Línea de trabajo

Start in lib/grape-swagger/doc_methods/move_params.rb at MoveParams#build_definition, then read the related issue and the request-body examples. Compare the generated specification with Grape's requirement for an object containing the array under a top-level key. Done means the specification represents the intended JSON object without requiring a dummy optional parameter.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

discuss!

Related issue: https://github.com/ruby-grape/grape-entity/issues/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. https://github.com/ruby-grape/grape/issues/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?

Lenguaje dominante
Ruby
Estrellas
1.1k
Forks
477
Merge medio
5 h 25 min
PR fusionados (30 d)
3

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ruby-grape/grape-swagger

Todos los issues de ruby-grape/grape-swagger

Issues similares

Más issues de Ruby

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.