grape-swagger icon indicating copy to clipboard operation
grape-swagger copied to clipboard

Invalid output for First-Class JSON Types

Open ktimothy opened this issue 8 years ago • 2 comments

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: 2017-06-10 23 34 06

ktimothy avatar Jun 10 '17 20:06 ktimothy

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 …

LeFnord avatar Jun 12 '17 13:06 LeFnord

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.)

ktimothy avatar Jun 13 '17 10:06 ktimothy