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

Param as type "array" in swagger_api #180

Open
toshitapandey opened this issue Mar 26, 2019 · 3 comments
Open

Param as type "array" in swagger_api #180

toshitapandey opened this issue Mar 26, 2019 · 3 comments

Comments

@toshitapandey
Copy link

I am trying to send a param with type array, but the params that I am getting in the controller is always of type string.

Swagger_api definition:
swagger_api :invite do
          summary 'Invite employees to organization'
          param :form, 'organization[emails]', :array, :optional, 'Employee emails (should be array)'
          param :header, 'auth-token', :string, :required, 'Authentication token'
          response :unauthorized
          response :not_acceptable, 'The request you made is not acceptable'
end
Generated swagger doc:

image

Params that I am getting in the controller:
=> <ActionController::Parameters {"organization"=>{"emails"=>"['[email protected]', '[email protected]']"}, "controller"=>"api/v1/organizations", "action"=>"invite"} permitted: false>

Is array even supported? Or do I need to change something here?

@vamsipavanmahesh
Copy link

@toshitapandey did you end up solving this?

@toshitapandey
Copy link
Author

@vamsipavanmahesh - no, I ended up changing my API format and had the frontend send it in the way that swagger sends it.

@vamsipavanmahesh
Copy link

we ended up changing from array to comma-separated string. Found this pattern in many sites, including JIRA @toshitapandey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants