ruby-grape / ruby-grape/grape-swagger

Invalid output for First-Class JSON Types

Open
#615 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
1.1k
Forks
479
Avg merge
2d 14h
Merged PRs (30d)
6

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the First-Class JSON Types example from the issue and inspect the generated Swagger parameter definitions. Trace how the nested JSON parameter and its int field are documented; done means the output represents the JSON structure correctly instead of exposing the nested field as a separate formData parameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.