mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
cleanup: add sync version of ExtractSpecInfoWithDocumentCheck
This commit is contained in:
@@ -51,6 +51,15 @@ func ExtractSpecInfoWithConfig(spec []byte, config *DocumentConfiguration) (*Spe
|
|||||||
return ExtractSpecInfoWithDocumentCheck(spec, config.BypassDocumentCheck)
|
return ExtractSpecInfoWithDocumentCheck(spec, config.BypassDocumentCheck)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ExtractSpecInfoWithDocumentCheckSync(spec []byte, bypass bool) (*SpecInfo, error) {
|
||||||
|
i, err := ExtractSpecInfoWithDocumentCheck(spec, bypass)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
<-i.GetJSONParsingChannel()
|
||||||
|
return i, nil
|
||||||
|
}
|
||||||
|
|
||||||
func ExtractSpecInfoWithDocumentCheck(spec []byte, bypass bool) (*SpecInfo, error) {
|
func ExtractSpecInfoWithDocumentCheck(spec []byte, bypass bool) (*SpecInfo, error) {
|
||||||
var parsedSpec yaml.Node
|
var parsedSpec yaml.Node
|
||||||
|
|
||||||
|
|||||||
@@ -52,14 +52,13 @@ func (rf *rolodexFile) Index(config *SpecIndexConfig) (*SpecIndex, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// first, we must parse the content of the file
|
// first, we must parse the content of the file
|
||||||
info, err := datamodel.ExtractSpecInfoWithDocumentCheck(content, config.SkipDocumentCheck)
|
info, err := datamodel.ExtractSpecInfoWithDocumentCheckSync(content, config.SkipDocumentCheck)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a new index for this file and link it to this rolodex.
|
// create a new index for this file and link it to this rolodex.
|
||||||
config.Rolodex = rf.rolodex
|
config.Rolodex = rf.rolodex
|
||||||
<-info.GetJSONParsingChannel() // TODO this almost makes the async parsing pointless, is there a later point to do this?
|
|
||||||
index := NewSpecIndexWithConfig(info.RootNode, config)
|
index := NewSpecIndexWithConfig(info.RootNode, config)
|
||||||
rf.index = index
|
rf.index = index
|
||||||
return index, nil
|
return index, nil
|
||||||
|
|||||||
@@ -182,12 +182,11 @@ func (l *LocalFile) Index(config *SpecIndexConfig) (*SpecIndex, error) {
|
|||||||
content := l.data
|
content := l.data
|
||||||
|
|
||||||
// first, we must parse the content of the file
|
// first, we must parse the content of the file
|
||||||
info, err := datamodel.ExtractSpecInfoWithDocumentCheck(content, true)
|
info, err := datamodel.ExtractSpecInfoWithDocumentCheckSync(content, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
<-info.GetJSONParsingChannel() // TODO this almost makes the async parsing pointless, is there a later point to do this?
|
|
||||||
index := NewSpecIndexWithConfig(info.RootNode, config)
|
index := NewSpecIndexWithConfig(info.RootNode, config)
|
||||||
index.specAbsolutePath = l.fullPath
|
index.specAbsolutePath = l.fullPath
|
||||||
|
|
||||||
|
|||||||
@@ -180,12 +180,11 @@ func (f *RemoteFile) Index(config *SpecIndexConfig) (*SpecIndex, error) {
|
|||||||
content := f.data
|
content := f.data
|
||||||
|
|
||||||
// first, we must parse the content of the file
|
// first, we must parse the content of the file
|
||||||
info, err := datamodel.ExtractSpecInfoWithDocumentCheck(content, true)
|
info, err := datamodel.ExtractSpecInfoWithDocumentCheckSync(content, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
<-info.GetJSONParsingChannel() // TODO this almost makes the async parsing pointless, is there a later point to do this?
|
|
||||||
index := NewSpecIndexWithConfig(info.RootNode, config)
|
index := NewSpecIndexWithConfig(info.RootNode, config)
|
||||||
index.specAbsolutePath = config.SpecAbsolutePath
|
index.specAbsolutePath = config.SpecAbsolutePath
|
||||||
f.index = index
|
f.index = index
|
||||||
|
|||||||
Reference in New Issue
Block a user