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

Array Object #31

Open
analyn-cajocson opened this issue Mar 28, 2017 · 3 comments
Open

Array Object #31

analyn-cajocson opened this issue Mar 28, 2017 · 3 comments

Comments

@analyn-cajocson
Copy link

Hi! I am now using this gem for my API. However, I'm having a hard time adding some parameters like array object.

This is my sample parameter on postman and I want to try this on swaggard.
screen shot 2017-03-28 at 4 19 40 pm

But I ended up having this:
screen shot 2017-03-28 at 4 21 29 pm

and this is my codes

#products_controller.rb

# Create product
#
# @body_parameter [string] sku
# @body_parameter [array] product_category_attributes
def create
product = Product.new(product_params)
if product.save
@http_response = product
@http_status = 200
else
@http_response = product.errors
end
render :json => @http_response, :status => @http_status
end

# strong parameters
def product_params
params.permit(
:sku,
product_category_attributes: [ :id, :category_id, :product_id,:_destroy ]
)
end

Looking forward for the fast response. Thank you!

@adrian-gomez
Copy link
Owner

adrian-gomez commented Jul 18, 2017

Hey, if want to document input parameters you need to define a class and add it to the models that are scanned by swaggard.

You can check this #21 for an example

@analyn34 Sorry for the late response

@analyn-cajocson
Copy link
Author

ok. I'll check this. thanks @adrian-gomez

@Seralto
Copy link

Seralto commented Dec 19, 2017

@analyn34, I have the same issue. Did you get it work using the example? If so, could you please post your code? Thanks.

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

3 participants