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

Generate API documentation #884

Open
baohouse opened this issue Apr 13, 2018 · 10 comments
Open

Generate API documentation #884

baohouse opened this issue Apr 13, 2018 · 10 comments

Comments

@baohouse
Copy link
Contributor

baohouse commented Apr 13, 2018

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!

@denys-medynskyi
Copy link

Hi @baohouse
I can do it, however, I don't see any API folder.
Can you point me which one should be documented?
Or which files exactly should be documented?

Also, regarding the API documentation.
I think the most easy to do and easy to maintain is markdown documentation with code snippets.

What do you think about markdown docs?

@member-cop
Copy link

member-cop bot commented Oct 5, 2018

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.

@julianguyen
Copy link
Member

@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.

@denys-medynskyi
Copy link

Do you mean by starting commenting existing endpoints?
Can you give me an example what you want in the end?

@member-cop
Copy link

member-cop bot commented Oct 6, 2018

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.

@julianguyen
Copy link
Member

julianguyen commented Oct 6, 2018

@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?

@baohouse
Copy link
Contributor Author

baohouse commented Oct 8, 2018

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

@member-cop
Copy link

member-cop bot commented Oct 8, 2018

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.

@julianguyen
Copy link
Member

Omg this bot lol

@alexiamcdonald
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Infrastructure
  
Awaiting triage
Development

No branches or pull requests

4 participants