Skip to content

Commit

Permalink
support embedded structures with alias instead of package name
Browse files Browse the repository at this point in the history
  • Loading branch information
ShoshinNikita committed Apr 10, 2020
1 parent 4c502aa commit b35892a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions parser.go
Expand Up @@ -859,6 +859,17 @@ func (parser *Parser) parseStructField(pkgName string, field *ast.Field) (map[st
}

typeSpec := parser.TypeDefinitions[pkgName][typeName]
if typeSpec == nil {
// Check if the pkg name is an alias and try to define type spec using real package name
if aliases, ok := parser.ImportAliases[pkgName]; ok {
for alias := range aliases {
typeSpec = parser.TypeDefinitions[alias][typeName]
if typeSpec != nil {
break
}
}
}
}
if typeSpec != nil {
schema, err := parser.parseTypeExpr(pkgName, typeName, typeSpec.Type)
if err != nil {
Expand Down

0 comments on commit b35892a

Please sign in to comment.