fix issue: https://github.com/zeromicro/goctl-swagger/issues/6 (#680)
This commit is contained in:
@@ -18,6 +18,7 @@ type (
|
|||||||
debug bool
|
debug bool
|
||||||
log console.Console
|
log console.Console
|
||||||
antlr.DefaultErrorListener
|
antlr.DefaultErrorListener
|
||||||
|
src string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParserOption defines an function with argument Parser
|
// ParserOption defines an function with argument Parser
|
||||||
@@ -94,7 +95,8 @@ func (p *Parser) parse(filename, content string) (*Api, error) {
|
|||||||
var apiAstList []*Api
|
var apiAstList []*Api
|
||||||
apiAstList = append(apiAstList, root)
|
apiAstList = append(apiAstList, root)
|
||||||
for _, imp := range root.Import {
|
for _, imp := range root.Import {
|
||||||
path := imp.Value.Text()
|
dir := filepath.Dir(p.src)
|
||||||
|
path := filepath.Join(dir, imp.Value.Text())
|
||||||
data, err := p.readContent(path)
|
data, err := p.readContent(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -420,6 +422,7 @@ func (p *Parser) readContent(filename string) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.src = abs
|
||||||
data, err := ioutil.ReadFile(abs)
|
data, err := ioutil.ReadFile(abs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
Reference in New Issue
Block a user