18
bee generate docs
source link: https://studygolang.com/articles/31085
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
1. beego支持的注解
bee 1.12.0
path
, [httpMethod]
Title
用于标识操作的唯一字符串。在所有API操作中必须唯一。
Description
操作行为的详细说明。
Summary
该操作的简短摘要。
Success
以空格分隔的成功响应。 return code
, {param type}
, data type
, comment
Param
用空格分隔的参数。 param name
, param type
, data type
, is mandatory
, comment
Failure
以空格分隔的故障响应。 return code
, {param type}
, data type
, comment
Deprecated
接口不推荐使用
Security
每个API操作的 安全性 。
Accept
API可以使用的MIME类型的列表。值必须如“ Mime类型 ”中所述。
参数类型param type
- query
- path
- header
- body
- formData
数据类型data type
- string (string)
- integer (int, uint, uint32, uint64)
- number (float32)
- boolean (bool)
- array
- file
- basicTypes(`"bool": "boolean:",
"uint": "integer:int32",
"uint8": "integer:int32",
"uint16": "integer:int32",
"uint32": "integer:int32",
"uint64": "integer:int64",
"int": "integer:int64",
"int8": "integer:int32",
"int16": "integer:int32",
"int32": "integer:int32",
"int64": "integer:int64",
"uintptr": "integer:int64",
"float32": "number:float",
"float64": "number:double",
"string": "string:",
"complex64": "number:float",
"complex128": "number:double",
"byte": "string:byte",
"rune": "string:byte",
// builtin golang objects
"time.Time": "string:datetime",
"json.RawMessage": "object:",) - user defined struct
参数示例Param
// @Param string query string true "string valid" // @Param int query int false "int valid" // @Param default query string default(A) false "string default" // @Param collection query []string false "string collection"
1.1 @Success支持的类型
@Success
2. bee解析router.go引用的文件
2.1 源文件
controller.go
2.2 解析Controller之后的结果
parse controller
3. router.go 必须满足以下条件,否则Controller的注解不会生成到swagger中
3.1 router.go中必须有要生成注解的Controller的引用
imports
3.2 router.go中关于引用的controller内容必须包含赋值语句
stmt
即形如:
AssignStmt
如果没有这个 _ =
,这里的语句将是: ExprStmt
- 包含单独的表达式语句。
更多类型见: golang深入源代码系列之一:AST的遍历
3.3 router.go中赋值语句必须包含 NewNamespace
和( NSNamespace
或 NSInclude
)
Namespace
即形如:
Namespace
有疑问加站长微信联系
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK