fix: 兼容二维数组生成, 更新 go

This commit is contained in:
Young 2022-05-31 09:57:37 +08:00
parent cce0278970
commit 58f17b3c24
3 changed files with 25 additions and 20 deletions

View File

@ -30,6 +30,7 @@ type (
Birthday string `json:"birthday"` Birthday string `json:"birthday"`
Description string `json:"description"` Description string `json:"description"`
Tag []string `json:"tag"` Tag []string `json:"tag"`
Tags [][]string `json:"tags"`
} }
UserSearchReq { UserSearchReq {

View File

@ -36,7 +36,6 @@
} }
} }
], ],
"requestBody": {},
"tags": [ "tags": [
"user-api" "user-api"
] ]
@ -63,7 +62,6 @@
} }
} }
], ],
"requestBody": {},
"tags": [ "tags": [
"user-api" "user-api"
] ]
@ -90,7 +88,6 @@
"type": "string" "type": "string"
} }
], ],
"requestBody": {},
"tags": [ "tags": [
"user-api" "user-api"
] ]
@ -116,7 +113,6 @@
"type": "string" "type": "string"
} }
], ],
"requestBody": {},
"tags": [ "tags": [
"user-api" "user-api"
] ]
@ -183,6 +179,15 @@
"items": { "items": {
"type": "string" "type": "string"
} }
},
"tags": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "string"
}
}
} }
}, },
"title": "UserInfoReply", "title": "UserInfoReply",
@ -191,20 +196,13 @@
"age", "age",
"birthday", "birthday",
"description", "description",
"tag" "tag",
"tags"
] ]
}, },
"UserInfoReq": { "UserInfoReq": {
"type": "object", "type": "object",
"properties": { "title": "UserInfoReq"
"id": {
"type": "string"
}
},
"title": "UserInfoReq",
"required": [
"id"
]
}, },
"UserSearchReq": { "UserSearchReq": {
"type": "object", "type": "object",
@ -227,10 +225,5 @@
"name": "Authorization", "name": "Authorization",
"in": "header" "in": "header"
} }
}, }
"security": [
{
"apiKey": []
}
]
} }

View File

@ -390,6 +390,17 @@ func schemaOfField(member spec.Member) swaggerSchemaObject {
core = schemaCore{Type: "object"} core = schemaCore{Type: "object"}
} else if refTypeName == "mapstringstring" { } else if refTypeName == "mapstringstring" {
core = schemaCore{Type: "object"} core = schemaCore{Type: "object"}
} else if strings.HasPrefix(refTypeName, "[]") {
core = schemaCore{Type: "array"}
tempKind := swaggerMapTypes[strings.Replace(refTypeName, "[]", "", -1)]
ftype, format, ok := primitiveSchema(tempKind, refTypeName)
if ok {
core.Items = &swaggerItemsObject{Type: ftype, Format: format}
} else {
core.Items = &swaggerItemsObject{Type: ft.String(), Format: "UNKNOWN"}
}
} else { } else {
core = schemaCore{ core = schemaCore{
Ref: "#/definitions/" + refTypeName, Ref: "#/definitions/" + refTypeName,