Skip to content

Bug report: omitted array parameters with array_use_braces: true #952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
olivier-thatch opened this issue May 8, 2025 · 2 comments · May be fixed by #957
Open

Bug report: omitted array parameters with array_use_braces: true #952

olivier-thatch opened this issue May 8, 2025 · 2 comments · May be fixed by #957

Comments

@olivier-thatch
Copy link

When array_use_braces is set to true, array parameters are omitted when they are body parameters but don't explicitly specify documentation: { param_type: "body" }.

Example:

# with add_swagger_documentation(array_use_braces: true)

params do
  requires :param1, type: Array[String]
  requires :param2, type: Array[Integer], documentation: { param_type: "body" }
end
post :foo do
  { declared_params: declared(params)
end

The spec will look like:

"postFoo": {
  "required": ["param2"],
  "type": "object",
  "properties": {
    "param2": {
      "type": "array",
      "items": { "type": "integer", "format": "int32" }
    }
  }
}

It is particularly annoying if one wants to share some params between GET and POST/PUT/PATCH endpoints and rely on the implicit behavior to have the params be query params or body params as appropriate.

@olivier-thatch
Copy link
Author

I didn't spend too much time looking into this, but I think this happens because:

Probably the check needs to be updated to exclude foo[] and only treat foo[bar] as nested params?

@dblock
Copy link
Member

dblock commented May 18, 2025

Please do try to PR a fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants