Skip to content

Allow multiple parameter types #693

Closed
@dblock

Description

@dblock

I have the following API: /api/v1/artworks/tagged?tag[]=, I'd like to be able to do /api/v1/artworks/tagged?tag=painting as well as /api/v1/artworks/tagged?tag[]=painting&tag[]=sculpture. So something like this:

params do
  requires :tag, types: [String, Array[String]], desc: "Tag or tags."
end

Maybe instead I could write this:

params do
  optional :tag, type: String, desc: "Tag or tags."
  optional :tag, type: Array[String], desc: "Tag or tags."
  exactly_one_of :tag
end

That would also solve the problem of allowing a parameter like size to be a number (eg. 10) or a string, (eg. "all").

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions