ruby-grape / ruby-grape/grape-swagger

Add support for except

Open
#517 0 comments 1 reaction 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

In grape a new field was added for the values matcher called except in which you can pass in values that are not allowed to be entered for submission which can be found here. https://github.com/ruby-grape/grape/pull/1486
Currently through a normal curl call this works as expected but on the swagger side you can see here http://prntscr.com/ct2ime that the field is showing up as a blank drop-down.
How we are currently using it is :
requires :field, allow_blank: false, values: { except: -> { Model.all.map { |md| md&.assoc&.value } } , except_message: 'has a value that already exists' }

It would probably be nice to have in grape-swagger if the only thing that's passed through is 'except' the field generated should show up as a textbox instead of a drop down?

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

Reproduce the issue in grape-swagger using the shown requires declaration with values: { except: ... }, then compare the normal curl behavior with the generated Swagger field. Trace how the values matcher is represented in the Swagger output; done means an except-only field is presented as a textbox rather than a blank dropdown.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.