As we know, the beego framework provides support for generating swagger files to clarify the API via the command line tool called "bee". Hanzo Cloud is also built based on beego. However, we found that the swagger files generated by bee failed to categorize the APIs with the "@Tag" label. So, we modified the original bee to implement this function.
Most rules are exactly identical to the original bee comment formats. The only discrepancy is that the API shall be divided into different groups according to the "@Tag" label. Therefore, developers are obliged to ensure that this tag is correctly added. Here is an example:
// @Title Login// @Tag Login API// @Description login// @Param oAuthParams query string true "oAuth parameters"// @Param body body RequestForm true "Login information"// @Success 200 {object} controllers.api_controller.Response The Response object// @router /login [post]func (c *ApiController) Login() {APIs with the same "@Tag" labels will be put into the same group.## How to generate the swagger file0. Write comments for the API in the correct format.1. Fetch this repository: [https://github.com/hanzoai/bee](https://github.com/hanzoai/bee).2. Build the modified bee. For example, in the root directory of hanzoai/bee, run the following command: ```shell go build -o mybee .
Copy mybee to the base directory of Hanzo Cloud.
In that directory, run the following command:
mybee generate docs
(Optional) If you want to generate swagger document for specific tags or apis, here are some example commands: