@Api
is a commonly used annotation used to mark and describe RESTful API interfaces in Java code.
@Api
Annotations are usually used together with other annotations (such as @RestController
, @RequestMapping
etc.) to provide metadata and documentation information for the API. It can be used at both class level and method level.
At the class level, @Api
annotations are used to describe information about the entire API controller class, including the name, description, author, etc. of the API.
At the method level, @Api
annotations are used to describe information about a single API interface, including the name, description, parameters, return values, etc. of the interface.
Here are @Api
some common properties of annotations:
value
: Specify the name of the API.tags
: Specify the label of the API, used to classify the API.description
: Describe the functions and functions of the API.produces
: Specify the response content type of the API.consumes
: Specifies the request content type accepted by the API.authorizations
: Specify the security authentication requirements of the API.hidden
: Specify whether to hide the API.
Using @Api
annotations can provide a description of the documentation and metadata of the API interface, making it easier for developers and users to understand and use the interface. This information can be parsed and displayed by automatically generated API documentation tools (such as Swagger).
It should be noted that @Api
annotations themselves do not affect the actual functions and logic of the API, they just provide a way to mark and describe the API.