rspec_api_documentation icon indicating copy to clipboard operation
rspec_api_documentation copied to clipboard

Ability to indicate an array in response parameters.

Open jeffutter opened this issue 10 years ago • 4 comments

I can't seem to find anywhere this is mentioned in the docs or tests. Is there any way to indicate that parameters are in an array of like objects?

For example, with the response

{
  "users": [
    {
      "id": 1,
      "username": "foo"
    },
    {
      "id": 2,
      "username": "bar"
    }
  ]
}

would have response parameters like:

users[id]
users[username]

I would expect some way to output:

users[][id]
users[][username]

Am I missing something? Any thoughts?

jeffutter avatar Oct 26 '15 23:10 jeffutter

I do not believe that this is possible right now. This is the response_field DSL? I can't think of a nice way around this, I will be happy to look at a PR if this is still an issue.

My first thought is to allow you to pass an extra option to the response_field call specifying exactly what the return scoping/field will be, :field => "users[][id] perhaps. This might be cumbersome quick though.

oestrich avatar Feb 01 '16 20:02 oestrich

I know this is older but any updates around this? has anyone found a solution?

h55nick avatar Jun 07 '16 18:06 h55nick

Has anyone found a solution? It is still actual 😓

kopylovvlad avatar Jan 21 '19 08:01 kopylovvlad

I have found a solution: https://github.com/zipmark/rspec_api_documentation/issues/430

kopylovvlad avatar Jan 21 '19 10:01 kopylovvlad