doc-apis doc-apis
💋Home
  • v1.0.0(current verison)
  • What's New

    • What' s New In doc-apis v1.0.0 ?
💖Charge
  • Community
  • Project PPT (opens new window)
  • Introduction
  • Member
  • PR
  • Join us
  • Customer
  • Easy-Es (opens new window)
  • Fit-Plan-Generator (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • English (opens new window)
  • 简体中文 (opens new window)

Advs are displayed by random carousel. ❤️Become a sponsor
💋Home
  • v1.0.0(current verison)
  • What's New

    • What' s New In doc-apis v1.0.0 ?
💖Charge
  • Community
  • Project PPT (opens new window)
  • Introduction
  • Member
  • PR
  • Join us
  • Customer
  • Easy-Es (opens new window)
  • Fit-Plan-Generator (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • English (opens new window)
  • 简体中文 (opens new window)
  • Quick Start Guide

    • Introduction
    • Applicable scenarios
    • Concerns rushed
    • Quick start demo
    • Other projects
    • Config
    • Annotation
      • @DocApi
      • @DocIgnore
  • Expand function

    • Interface debug
  • Others

    • FAQ
    • Update log
    • Update plan
    • Copyright
    • Acknowledgments
  • v1.xDocument
  • Quick Start Guide
LaoHan
2023-03-18
目录
@DocApi
@DocIgnore

Annotation

# @DocApi

By default, doc-apis generates documentation for all interfaces within the project that conform to its built-in rules (rules include annotations such as @RestController󠁪 or @Controller󠁪, among others). If you do not wish to document every interface, you can disable this default behavior by setting doc-apis.autoGenerate=false󠁪, as mentioned in the previous configuration section. After disabling auto-generation, you can selectively designate which interfaces should be documented using the @DocApi󠁪 annotation.When applied to an interface method,

@DocApi󠁪 offers additional flexible settings:

  • result: Directly declare the return object type. If specified, it overrides the SpringBoot return object.
  • stringResult: Use this for returning a string when the response is simple, and creating a dedicated return class is unnecessary.
  • url: An extension field for specifying the request URL, useful for non-SpringBoot projects.
  • method: An extension field indicating the request method, helpful for non-SpringBoot scenarios.

Example:

@DocApi(result = AdminVO.class, url = "/api/v1/admin/auth", method = "post")
public void someMethod();
1
2

stringResult󠁪, where the JSON string will be automatically formatted in the documentation:

@DocApi(stringResult = "{code: 200, data: 'success'}")
@GetMapping("custom-json")
public Map<String, Object> customJsonResult() { ... }
1
2
3

# @DocIgnore

Ignoring Specific ControllersTo ignore an entire Controller󠁪, simply annotate the class with @DocIgnore

@DocIgnore
public class UserController {
    // ...
}
1
2
3
4

Ignoring Specific MethodsAlternatively, apply @DocIgnore󠁪 to a specific method to exclude just that method from documentation, providing finer control:

@PostMapping("save")
@DocIgnore
public ApiResult saveUser() {
    return null;
}

1
2
3
4
5
6

Ignoring Specific FieldsTo exclude a field from being exported in the generated documentation, annotate that field with @DocIgnore:

public class User {
    // ...

    /**
     * Name
     */
    @DocIgnore
    private String name;
}
1
2
3
4
5
6
7
8
9

Special Notes

  1. By default, the framework uses the comment content above the Controller󠁪 class as the navigation title in the documentation. However, if the comment includes @description󠁪, that text will be used instead. For example:
/**
 * Demonstrates some special declaration methods
 *
 * @description Administrator Interface
 */
@Controller
public class AdminController {
    // ...
}
1
2
3
4
5
6
7
8
9

In this case, the navigation title in the generated documentation will be "Administrator Interface," not "Demonstrates some special declaration methods."

2.Adding @description󠁪 within a method's comments allows you to append a line of additional explanation beneath the interface method. For example:

/**
 * User List
 * @description Frontend developers, please note, all responsibility lies with the frontend.
 */
@PostMapping("/list")
public ApiResult<List<User>> listUser() { ... }
1
2
3
4
5
6

Here, the generated documentation will include an extra note under the interface method: "Frontend developers, please note, all responsibility lies with the frontend."

Help us improve this document (opens new window)
lastUpdated: 2024/07/12
Config
Interface debug

← Config Interface debug→

Theme by Vdoing | Copyright © 2024-2025 LaoHan | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式