文档必须存在属性优化处理
This commit is contained in:
@ -31,9 +31,12 @@ func NewOpenapiDoc(info *define.Info, servers []*define.ServerItem) *Generate {
|
||||
TermsOfService: "",
|
||||
Contact: nil,
|
||||
License: nil,
|
||||
Version: "",
|
||||
Version: "0.0.1",
|
||||
}
|
||||
}
|
||||
if len(info.Version) == 0 {
|
||||
info.Version = "0.0.1"
|
||||
}
|
||||
if nil == info.License {
|
||||
info.License = &define.License{
|
||||
Name: consts.LicenseApache20,
|
||||
@ -306,9 +309,9 @@ func (g *Generate) AddComponentsSchema(schemaName string, inputType reflect.Type
|
||||
inputType.Field(i).Type.Kind() == reflect.Map ||
|
||||
inputType.Field(i).Type.Kind() == reflect.Array ||
|
||||
inputType.Field(i).Type.Kind() == reflect.Slice {
|
||||
g.AddComponentsSchema(inputType.PkgPath(), inputType.Field(i).Type)
|
||||
g.AddComponentsSchema(schemaName+inputType.Field(i).Name, inputType.Field(i).Type)
|
||||
} else {
|
||||
g.docData.Components.Schemas[schemaName].Properties[inputType.Field(i).Type.String()] = &define.Property{
|
||||
g.docData.Components.Schemas[schemaName].Properties[inputType.Field(i).Name] = &define.Property{
|
||||
Type: "string",
|
||||
Format: inputType.Field(i).Type.String(),
|
||||
}
|
||||
|
Reference in New Issue
Block a user