Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allowMultiple #95

Closed
snackycracky opened this issue Mar 27, 2014 · 4 comments
Closed

allowMultiple #95

snackycracky opened this issue Mar 27, 2014 · 4 comments

Comments

@snackycracky
Copy link

Hello,

why can't I use the allowMultiple Fieldname described here:
https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#524-parameter-object

Actually I want the multiple option box from:
http://petstore.swagger.wordnik.com/#!/pet/findPetsByStatus

There are predefined values for a parameter with an enum "available, pending, sold":

{
         "path":"/pet/findByStatus",
         "operations":[
            {
               "method":"GET",
               "summary":"Finds Pets by status",
               "notes":"Multiple status values can be provided with comma seperated strings",
               "type":"array",
               "items":{
                  "$ref":"Pet"
               },
               "nickname":"findPetsByStatus",
               "authorizations":{

               },
               "parameters":[
                  {
                     "name":"status",
                     "description":"Status values that need to be considered for filter",
                     "defaultValue":"available",
                     "required":true,
                     "type":"string",
                     "paramType":"query",
                     "allowMultiple":true,
                     "enum":[
                        "available",
                        "pending",
                        "sold"
                     ]
                  }
               ],
               "responseMessages":[
                  {
                     "code":400,
                     "message":"Invalid status value"
                  }
               ]
            }
         ]
      },
@snackycracky
Copy link
Author

@antek-drzewiecki
Copy link
Contributor

#132 plus #105 might have fixed this.
You need to explicitly tell grape that the parameter type is an Array and that it has values. Note that the values need to be an Array in an Array.

params do
  optional :number, type: Array, desc: "Favourite number" , values: [[1],[2],[3]]
  optional :foo_or_bar , type: String, desc: "Foo or Bar?" , values: %w(Foo Bar)
end

Is the behaviour for param number the behaviour you want?

@hut8
Copy link

hut8 commented Oct 26, 2015

It looks like none of the specs actually test that allowMultiple can be generated. I'm trying to do this:

        optional :mapping, type: Hash, documentation: { is_array: true } do
          requires :from, type: String, desc: 'Mapping done from'
          requires :to, type: String, desc: 'Mapping goes to'
        end

relevant line in doc_methods.rb:

allowMultiple: is_array && data_type != 'array' && %w(query header path).include?(param_type)

What am I missing here? And why can't multiple values be in the body? Thanks.

@LeFnord
Copy link
Member

LeFnord commented Jan 13, 2017

impmented in actual versions

@LeFnord LeFnord closed this as completed Jan 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants