Apidoc is based on comments to generate the document, it is not based on any framework, and supports most programming languages, in order to springboot the integrity of the series, so a question.
I. Introduction of Apidoc
Apidoc generates API documentation by commenting on your code. It is not intrusive to the code, you only need to write the relevant comments, and it can only write a simple configuration to generate a high-Value API interface page. It is based on node. js, so you need to install the node. JS Environment. node. js installation, click here. It is not introduced here.
Ii. preparatory work
After installing node. JS installation Api.doc, it's project source: Https://github.com/apidoc/apidoc.
Install by command:
NPM Install Apidoc-g
Third, how to write notes
- @api
@api {method} path [Title]method: Request method, Path: Request path title (optional): Title
- @apiDescription
@apiDescription Texttext Instructions
- @apiError
@apiError [(Group)] [{type}] field [description] (group) (optional): parameter will be grouped by this name, not set, default is error 4xx {type} (optional): Return value type, for example: { Boolean}, {number}, {String}, {Object}, {string[]} field: Return Value field name descriptionoptional (optional): Return value field description
- @apiGroup
@apiGroup namename: Group name, also title of navigation
For more comments, see official documentation: http://apidocjs.com/#params
Iv. writing to chestnuts first write the configuration fileCreate a new Apidoc.json file in the project's home directory:
{ "name": "Example", "version": "0.1.0", "description": "A basic Apidoc Example"}
Write a comment: /** * @api {POST}/register registered user * @apiGroup users * @apiVersion 0.0.1 * @apiDescription for registered users * @ap Iparam {string} account username * @apiParam {string} password password * @apiParam {string} mobile phone number * @apiParam {in T} VIP = 0 whether to register VIP status 0 Normal User 1 VIP user * @apiParam {String} [recommend] invitation code * @apiParamExample {JSON} Request sample:
* ? account=sodlinken&password=11223344&mobile=13739554137&vip=0&recommend= * @ apisuccess {String} msg information * @apiSuccess (+) {int} code 0 means no error 1 for error * @apiSuccessExample {JSON} return sample: * {"Code": "0", "MSG": "Registered successfully"} */
Creating a document interface with the Apidoc commandThe first CD to the project's outer directory, and the outer layer to build an output document directory, I built the DOCAPI.
Output command:
apidoc -i chapter4/ -o apidoc/
-I input directory-o output directory
Chapter4 is the name of my project.
You can see that many files have been generated in the Apidoc directory:
Open index.html and you can see the document page:
Source Source
Enterprise Distribution Micro Service Cloud Springcloud springboot MyBatis (30) About Spring boot integration Apidoc