We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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
# 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
# strong parameters def product_params params.permit( :sku, product_category_attributes: [ :id, :category_id, :product_id,:_destroy ] ) end
# strong parameters
def product_params
params.permit(
:sku,
product_category_attributes: [ :id, :category_id, :product_id,:_destroy ]
)
Looking forward for the fast response. Thank you!
The text was updated successfully, but these errors were encountered:
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
Sorry, something went wrong.
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.
No branches or pull requests
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!
The text was updated successfully, but these errors were encountered: