Invalid output for First-Class JSON Types
Grape allows to define parameter as json and describe its structure: https://github.com/ruby-grape/grape#first-class-json-types. I was surprised to find out, that grape-swagger cannot handle it in the right way. The simplest example:
requires :json, type: JSON do
requires :int, type: Integer, values: [1, 2, 3]
end
Parameter definitions in swagger output:
"parameters": [
{
"in": "formData",
"name": "api_key",
"type": "string",
"required": true
},
{
"in": "formData",
"name": "json",
"type": "json",
"required": true
},
{
"in": "formData",
"name": "json[int]",
"type": "integer",
"format": "int32",
"enum": [
1,
2,
3
],
"required": true
}
]
That's what appears in documentation:

Hi @ktimothy … what is your expectation? How should the JSON type be translated into OAPI? Can you provide a spec for it, thanks
give Hash type a try:
requires :json, type: Hash do
requires :int, type: Integer, values: [1, 2, 3]
end
think, this is what you expect …
Hi @LeFnord! As OAPI 2.0 does not have a support for formData json strings, I expect that no parameters describing json structure are included in swagger json. A spec will take some time =)
(Also, OAPI 3.0 will allow to define a schema for json parameters, but it's completely different story.)