Use of ApiDoc

不言
不言Original
2018-04-03 16:14:386708browse

This article introduces you to the use of ApiDoc. Friends who are interested can take a look.

Description

apiDoc creates a documentation from API annotations in your source code

apiDoc is an interface document. Its creation method is based on Interface comments for your source code. We only need to write the corresponding documentation for the interface, and then use the apiDoc generation interface documentation tool to generate the documentation for easy management and viewing.

Configuration method

Use of ApiDoc

1. Install apidoc (what is npm??? Ask your front-end classmates yourself...)

npm install apidoc -g

Install http-server

npm install http-server -g

2. Add documentation (official example) to the interface and add it in front of the Controller entry method.

/**
 * @api {get} /user/:id Request User information
 * @apiName GetUser
 * @apiGroup User
 *
 * @apiParam {Number} id Users unique ID.
 *
 * @apiSuccess {String} firstname Firstname of the User.
 * @apiSuccess {String} lastname  Lastname of the User.
 */

3. Create apidoc.json (official example)

{
  "name": "example",
  "version": "0.1.0",
  "description": "apiDoc basic example",
  "apidoc": {
    "title": "Custom apiDoc browser title",
    "url" : "https://api.github.com/v1"
  }
}

4. Generate apiDoc

apidoc -i app/Http/Controllers -o apidoc/

5. Run

http-server api/doc

Additional remarks

Use of ApiDoc

Reference

http://apidocjs.com/




The above is the detailed content of Use of ApiDoc. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn