feature/fix_tag #7
25
generate.go
25
generate.go
@ -270,7 +270,7 @@ func (g *Generate) getApiDocBaseCfg(baseCfg *define.UriBaseConfig, paramType ref
|
||||
Summary: baseCfg.Summary,
|
||||
Description: baseCfg.Description,
|
||||
ExternalDocs: nil,
|
||||
OperationID: baseCfg.Method + "-" + baseCfg.Uri,
|
||||
OperationID: wrapper.String(baseCfg.Method + "-" + baseCfg.Uri).Md5().Value,
|
||||
Parameters: make([]*define.PathConfigParameter, 0),
|
||||
RequestBody: &define.RequestBody{
|
||||
Required: true,
|
||||
@ -451,7 +451,7 @@ func (g *Generate) AddComponentsSchema(rootSchemaName string, pkgPath string, in
|
||||
}
|
||||
inputNameArr := strings.Split(inputType.Name(), ".")
|
||||
inputName := inputNameArr[len(inputNameArr)-1]
|
||||
schemaName := strings.ReplaceAll(pkgPath+"."+inputName, "/", "-")
|
||||
schemaName := strings.ReplaceAll(pkgPath+"."+inputName, "/", ".")
|
||||
if schemaName == "-" {
|
||||
// 忽略的属性
|
||||
return schemaName
|
||||
@ -612,7 +612,7 @@ func (g *Generate) getSchemaRef(schemaName string) string {
|
||||
return ""
|
||||
}
|
||||
schemaName = strings.ReplaceAll(schemaName, "*", "") // 去除指针类型 *
|
||||
return "#/components/schemas/" + strings.ReplaceAll(schemaName, "/", "-")
|
||||
return "#/components/schemas/" + strings.ReplaceAll(schemaName, "/", ".")
|
||||
}
|
||||
|
||||
// realType2SwaggerType golang 真实数据类型转换为golang数据类型
|
||||
@ -725,5 +725,24 @@ func (g *Generate) parseBaseUriConfig(uriPrefix string, paramType reflect.Type)
|
||||
if res.Uri == "" {
|
||||
return nil, errors.New("baseCfg.Uri is empty")
|
||||
}
|
||||
if nil == g.docData.Tags {
|
||||
g.docData.Tags = make([]*define.TagItem, 0)
|
||||
}
|
||||
// 增加tag
|
||||
for _, itemTag := range res.TagList {
|
||||
exist := false
|
||||
for _, t := range g.docData.Tags {
|
||||
if itemTag == t.Name {
|
||||
exist = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !exist {
|
||||
g.docData.Tags = append(g.docData.Tags, &define.TagItem{
|
||||
Name: itemTag,
|
||||
Description: itemTag,
|
||||
})
|
||||
}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user