ruby-grape / ruby-grape/grape

how to define multiple allowed types with values?

Open
#2,151 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
Ruby
Stars
10k
Forks
1.2k
Avg merge
14h 38m
Merged PRs (30d)
92

Description

Let say I have an API parameter, I wanna the parameter accept a boolean or a string

optional :status, types: [Boolean, String]

As I wanna scoped the string value, but I found that I cant define as below
optional :status, types: [Boolean, String], values: %w(active hidden draft)

May I know how to achieve this objective?

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

The issue names no file, test, or entry point. Start by tracing how Grape handles optional parameters with multiple types and values, then clarify the expected validation behavior for booleans and the three listed strings; done means that behavior is specified and covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.