-
Notifications
You must be signed in to change notification settings - Fork 742
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
Generate API documentation #884
Comments
Hi @baohouse Also, regarding the API documentation. What do you think about markdown docs? |
Hey @denysmedynskyi, thanks for expressing your interest. We would love your help with this issue. Please follow these next steps to join our contributor community. |
@denysmedynskyi So we don't have API docs at all, so this would be starting from scratch. While working on this, I wouldn't remove the logic that exists in the controller as we need backward compatibility. |
Do you mean by starting commenting existing endpoints? |
Hey @denysmedynskyi, thanks for expressing your interest. We would love your help with this issue. Please follow these next steps to join our contributor community. |
@denysmedynskyi Great question. I think we want to extend the existing API have in our controller but write them in a way so that it can easily be used in the client without relying on Rails views and routing. We would want proper JSON responses. Generating docs would be helpful too, Swagger UI is great for that. @baohouse was there anything else I missed? |
Yah, Swagger is probably the tool of choice; can't go wrong with that. If we're using Swagger, then the work here is not so much creating JSON input/output, but is more about properly annotating the controller. It would look like this: https://www.sitepoint.com/do-the-right-thing-and-document-your-rails-api-with-swagger/ class Api::V1::UsersController < ApplicationController
.....
# POST /users
swagger_api :create do
summary "To create user"
notes "Implementation notes, such as required params, example queries for apis are written here."
param :form, "user[name]", :string, :required, "Name of user"
param :form, "user[age]", :integer, :optional, "Age of user"
param_list :form, "user[status]", :string, :required, "Status of user, can be active or inactive"
response :success
response :unprocessable_entity
response :500, "Internal Error"
end
def create
@user = User.new(user_params)
if @user.save
render json: @user, status: :created
else
render json: @user.errors, status: :unprocessable_entity
end
end
.....
end |
Hey @baohouse, thanks for expressing your interest. We would love your help with this issue. Please follow these next steps to join our contributor community. |
Omg this bot lol |
Hello! I started this but I have become stuck on react component issues. Maybe if someone who knows react better than me could have a look that would be great. |
Description
It would be useful to have API documentation using a generator.
This will also be useful for #883.
Please assign yourself (via the Assignees dropdown), if you do want to work on this issue. Can't find yourself? You need to join our organization.
Check out our Picking Up Issues guide if you haven't already!
The text was updated successfully, but these errors were encountered: