Use of ApiDoc

不言
Release: 2023-03-23 07:14:01
Original
6639 people have browsed it

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
Copy after login

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
Copy after login

Install http-server

npm install http-server -g
Copy after login

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.
 */
Copy after login

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"
  }
}
Copy after login

4. Generate apiDoc

apidoc -i app/Http/Controllers -o apidoc/
Copy after login

5. Run

http-server api/doc
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!