grape-swagger
grape-swagger copied to clipboard
Cannot get Array of Hash working
Thanks for building this great bridge between swagger and grape.
I have spent a good bit of time trying to get the following to work, I have even created a minor rails test environment to see if the complicated setup is the cause but I can reproduce it with only a few lines of code.
I'd like to create an order with multiple order lines.
require 'grape-swagger'
module Twitter
class API < Grape::API
format :json
prefix :api
resource :orders do
desc 'Create an order'
params do
optional :order_type
optional :order_lines, type: Array do
optional :product
optional :quantity, type: Integer
end
end
post do
params
end
end
add_swagger_documentation
end
end
This gives me the following swagger-ui result

I was really hoping it would allow for these nested order-lines to work. However checking the curl line the posted output is not as expected:
I'd expect it to post order_lines[0][product]='cheese'&order_lines[0][quantity]=1
Also I think the UI looks funky, but that might be just swagger?
I'm really at a loss here if this is a grape-swagger, grape or swagger-ui issue, I am hoping you guys know what is wrong with my example.
Did you ever get it solved?
No unfortunately not :(
Sounds like a bug, cause if I run a curl command, it works without any issues.
I have the same issue, Array of Hashes is not properly shown in the UI
Please address +1, Have a similar issue after my frontend developer pointed out he could now see the array params.
Please contribute @TheAbyss.
+1
+1
+1, this is quite a big issue.
+1
+1
+1
+1
+1
Please add this feature. Any workaround on this.
Please add this feature @rabendrasharma.
+1
+1
could the maintainer of this package speak his mind about this?
Speaking on behalf of the maintainers, nobody is sure why this happens, and nobody has been working on this. At the very least someone should actually dig up where the issue is, to start.
I think the problem lies that the hash is eventually being passed to method coerced?(value) in the
Coercible::Coercer with value being a hash and its failing so its throwin a validation error
Isn't it fixed with this PR ? https://github.com/ruby-grape/grape-swagger/pull/752
With the condition to put 'documentation: { param_type: 'body' }' in the definition of a top level object
What version if grape swagger?
On Fri, Jan 17, 2020, 5:42 AM Gwénaël Rault [email protected] wrote:
Isn't it fixed with this PR ? #752 https://github.com/ruby-grape/grape-swagger/pull/752
With the condition to put 'documentation: { param_type: 'body' }' in the definition of a top level object
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ruby-grape/grape-swagger/issues/617?email_source=notifications&email_token=ADTJ6OZMERAOITHLGI35HZDQ6GDTDA5CNFSM4DRVOFTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJHI5NI#issuecomment-575573685, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADTJ6O2A5QO6PAONXCXW543Q6GDTDANCNFSM4DRVOFTA .
It was integrated within the version 0.34
Sorry to bother you again I upgrade my grape-swagger. I am using pagination in one of my endpoints and now I'm getting nomethoderror on the method pagination I'm using grape-kaminari 0.1.9. Doesn't seem to be a more updated version
On Fri, Jan 17, 2020, 7:53 AM Gwénaël Rault [email protected] wrote:
It was integrated within the version 0.34
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ruby-grape/grape-swagger/issues/617?email_source=notifications&email_token=ADTJ6OZEV7UY55J5WQP6MH3Q6GS5XA5CNFSM4DRVOFTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJHS2RA#issuecomment-575614276, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADTJ6O3OI2UAQSOLSZ4QRXLQ6GS5XANCNFSM4DRVOFTA .