ruby-grape / ruby-grape/grape-swagger

grape/swagger POST arrays with embedded params don't work correctly in the UI

Open
#302 6 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

code like this:

desc 'create new symptom'
    params do
      optional :id, type: Integer
      requires :reasonCode, type: String
      requires :lifeThreatening, type: Boolean
      requires :msp, type: Boolean
      optional :symptomNamesAttributes, type: Array, default: [] do
          requires :name, type: String
          requires :primary, type: Boolean, default: false
      end
  end
end
screen shot 2015-10-02 at 2 53 12 pm

The area of interest is the SymtomNamesAttributes.

First problem: you can only enter one symtomNamesAttributes despite it being declared as an array.
Second (bigger problem): even though symtomNamesAttributes is marked as "optional", the UI makes it required because the nested names/primary fields are required.

Are these known issues? Is there a work around?

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 reported Grape parameter block in the Swagger UI, focusing on symptomNamesAttributes. Trace how the nested array and its required name/primary fields are represented. Done means the UI permits multiple array entries and does not require the optional nested parameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.