From 78a63b53c45953eb34494b78e687cb365f0e3124 Mon Sep 17 00:00:00 2001 From: Davide Nabais Date: Mon, 11 Sep 2023 15:34:07 +0100 Subject: [PATCH] - fallback to inline comment --- comment_extractor.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/comment_extractor.go b/comment_extractor.go index 0088b41..a4bf1ef 100644 --- a/comment_extractor.go +++ b/comment_extractor.go @@ -2,15 +2,14 @@ package jsonschema import ( "fmt" - "io/fs" - gopath "path" - "path/filepath" - "strings" - "go/ast" "go/doc" "go/parser" "go/token" + "io/fs" + gopath "path" + "path/filepath" + "strings" ) // ExtractGoComments will read all the go files contained in the provided path, @@ -69,6 +68,9 @@ func ExtractGoComments(base, path string, commentMap map[string]string) error { } case *ast.Field: txt := x.Doc.Text() + if txt == "" { + txt = x.Comment.Text() + } if typ != "" && txt != "" { for _, n := range x.Names { if ast.IsExported(n.String()) {