You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
grape-swagger generates an OpenAPI schema where the default value is incorrectly placed inside items, instead of being set at the array level. This causes the field to be interpreted as a nested array ([[value]]) in Swagger tools and breaks the expected structure.
🔍 Current Behavior (Incorrect)
Generated OpenAPI snippet:
dns_servers:
type: arrayitems:
type: stringdefault: ["8.8.8.8", "8.8.4.4"] # ❌ incorrect placement — default on items must be a single value, not an array
⚠️ Swagger Editor interprets this as:
"dns_servers": [
["8.8.8.8", "8.8.4.4"]
]
Which is not the intended behavior, and breaks compatibility with clients, documentation, and tools.
The default value represents what would be assumed by the consumer of the input if one is not provided. It MUST conform to the defined type for the schema object.
💡 Suggestion: when generating schemas from type: [String] with a default, grape-swagger should ensure the default is set at the array level — not inside items, and that its type conforms to OpenAPI expectations.
The text was updated successfully, but these errors were encountered:
Summary
When using the following parameter declaration in Grape:
grape-swagger
generates an OpenAPI schema where thedefault
value is incorrectly placed insideitems
, instead of being set at the array level. This causes the field to be interpreted as a nested array ([[value]]
) in Swagger tools and breaks the expected structure.🔍 Current Behavior (Incorrect)
Generated OpenAPI snippet:
Which is not the intended behavior, and breaks compatibility with clients, documentation, and tools.
✅ Expected Behavior
The correct OpenAPI output should look like this:
This correctly documents a default array of strings, not a nested array of arrays.
🧪 Minimal Reproducible Example (Swagger Editor — OpenAPI 2.0 - https://editor.swagger.io)
✅ Correct version for comparison:
📚 Specification Insights (OpenAPI & JSON Schema)
OpenAPI 3.0 Schema Object:
Swagger 2.0 Items Object:
JSON Schema - enum:
JSON Schema - default:
🔎 Why this matters
default
insideitems
implies a per-item default, which is not meaningful for array parameters.default
insideitems
(which expects a scalar) leads to nested arrays and invalid schemas.🔗 Related
📦 Version Info
ruby
:3.3.4
grape
:2.3.0
grape-swagger
:2.1.2
💡 Suggestion: when generating schemas from
type: [String]
with adefault
,grape-swagger
should ensure thedefault
is set at the array level — not insideitems
, and that its type conforms to OpenAPI expectations.The text was updated successfully, but these errors were encountered: