swaggard
swaggard copied to clipboard
Array Object
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.
But I ended up having this:
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!
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 https://github.com/adrian-gomez/swaggard/issues/21 for an example
@analyn34 Sorry for the late response
ok. I'll check this. thanks @adrian-gomez
@analyn34, I have the same issue. Did you get it work using the example? If so, could you please post your code? Thanks.