Enterprise Distribution Micro Service Cloud Springcloud springboot MyBatis (30) About Spring boot integration Apidoc

Source: Internet
Author: User

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 file

    Create 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 command

    The 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.