diff --git a/processor/processor.go b/processor/processor.go index 09caa79..fe95de7 100644 --- a/processor/processor.go +++ b/processor/processor.go @@ -283,7 +283,7 @@ func (p *processor) processType(pkg *loader.Package, info *markers.TypeInfo, dep return p.processStructFields(typeDef, pkg, info, depth) } - t := pkg.TypesInfo.TypeOf(info.RawSpec.Type) + t := pkg.TypesInfo.TypeOf(info.RawSpec.Name) if t == nil { zap.S().Warnw("Failed to determine AST type", "package", pkg.PkgPath, "type", info.Name) typeDef.Kind = types.UnknownKind diff --git a/test/api/v1/guestbook_types.go b/test/api/v1/guestbook_types.go index 7a6d69d..41daff2 100644 --- a/test/api/v1/guestbook_types.go +++ b/test/api/v1/guestbook_types.go @@ -48,6 +48,12 @@ type EmbeddedX struct { X string `json:"x,omitempty"` } +// NOTE: Rating is placed here to ensure that it is parsed as a standalone type +// before it is parsed as a struct field. + +// Rating is the rating provided by a guest. +type Rating string + // GuestbookSpec defines the desired state of Guestbook. type GuestbookSpec struct { // Page indicates the page number @@ -102,9 +108,6 @@ type GuestbookList struct { Items []Guestbook `json:"items"` } -// Rating is the rating provided by a guest. -type Rating string - func init() { SchemeBuilder.Register(&Guestbook{}, &GuestbookList{}) }