Skip to content
Permalink
Browse files

fix bug: []map[string]string type will crash (#286)

* fix bug: []map[string]string type will crash!

* add test data

* add more test data
  • Loading branch information...
windprog authored and easonlin404 committed Jan 23, 2019
1 parent 2a57949 commit 7cb56155ce638f23b574c302b01bbc860a99e30d
Showing with 17 additions and 2 deletions.
  1. +3 −2 parser.go
  2. +7 −0 parser_test.go
  3. +7 −0 testdata/simple/api/api.go
@@ -541,8 +541,9 @@ func (parser *Parser) parseTypeExpr(pkgName, typeName string, typeExpr ast.Expr)
case *ast.Ident:
refTypeName := fullTypeName(pkgName, expr.Name)
if _, isParsed := parser.swagger.Definitions[refTypeName]; !isParsed {
typedef := parser.TypeDefinitions[pkgName][expr.Name]
parser.ParseDefinition(pkgName, expr.Name, typedef)
if typedef, ok := parser.TypeDefinitions[pkgName][expr.Name]; ok{
parser.ParseDefinition(pkgName, expr.Name, typedef)
}
}
return parser.swagger.Definitions[refTypeName]

@@ -455,6 +455,13 @@ func TestParseSimpleApi1(t *testing.T) {
}
},
"definitions": {
"api.SwagReturn": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": {}
}
},
"cross.Cross": {
"type": "object",
"properties": {
@@ -107,3 +107,10 @@ func GetPet5b() {
func GetPet5c() {

}

type SwagReturn []map[string]string

// @Success 200 {object} api.SwagReturn "ok"
func GetPet6MapString() {

}

0 comments on commit 7cb5615

Please sign in to comment.
You can’t perform that action at this time.