Apidoc generator tutorial simple steps



Follow the steps to setup Api doc:


1. Run this command for install Apidoc in Ubuntu or follow the steps from http://apidocjs.com/#install
npm install apidoc -g

2. Read the documentation.

3. Example documentation that can be used:
    /**
     * @api {post} /end_user_login  end_user_login
     * @apiVersion 1.0.0
     * @apiName end_user_login
     * @apiGroup YummyApis   
     *
     *
     * @apiParam {string} email mandatory Email id as login credential
     * @apiParam {string} password mandatory Password as login credential
     * @apiParam {string} languages_id mandatory Language id  for restaurant details in that language
     *
     *
     * @apiSuccess {json} data Contain the API access token.
     *
     *
     * @apiSuccessExample Success-Response:
     *     HTTP/1.1 200 OK
        {
            "success": true,
            "token": "eyJ0jzdxYGm43TUM1MZGMs",
            "data": {
                "user_details": {
                "user_id": 496,
                "first_name": test,
                "last_name": test,
                }
            }
        }
     *
     *
     * @apiError InvalidCredential Invalid username or password.
     *
     * @apiErrorExample InvalidCredential:
     *     HTTP/1.1 401 Unauthorized
    {
    "success": false,
    "data": {
    "message": [
    "invalid credentials"
    ]
    }
    }
     */


2. Go to the controller folder or the folder where apis are written and run this command.

apidoc -i ./ -o apidoc/ 

3. In the controller folder you will see the api doc folder is created and then open index.html you will see documented apis will be open in browser.

4. One can do changes and again run the command:
apidoc -i ./ -o apidoc/ 

5. You can create json file and with name apidoc.json for global configurations for api doc and place in folder where you running command for generating api doc. Example of that apidoc.json:

{
  "name": "Api Documentation",
  "version": "1.0.0",
  "description": "List of apis"

}

Comments