mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 12:37:49 +00:00
Instead of using "root.yaml" as a theoretical root, use the real filename of the root spec (often openapi.yaml). This fixes issues with resolving references in rules such as unsused-components.
This commit is contained in:
@@ -39,6 +39,9 @@ type DocumentConfiguration struct {
|
||||
// To avoid sucking in all the files, set the FileFilter to a list of specific files to be included.
|
||||
BasePath string // set the Base Path for resolving relative references if the spec is exploded.
|
||||
|
||||
// SpecFilePath is the name of the root specification file (usually named "openapi.yaml").
|
||||
SpecFilePath string
|
||||
|
||||
// FileFilter is a list of specific files to be included by the rolodex when looking up references. If this value
|
||||
// is set, then only these specific files will be included. If this value is not set, then all files will be included.
|
||||
FileFilter []string
|
||||
|
||||
@@ -45,6 +45,7 @@ func createDocument(info *datamodel.SpecInfo, config *datamodel.DocumentConfigur
|
||||
idxConfig.AvoidCircularReferenceCheck = true
|
||||
idxConfig.BaseURL = config.BaseURL
|
||||
idxConfig.BasePath = config.BasePath
|
||||
idxConfig.SpecFilePath = config.SpecFilePath
|
||||
idxConfig.Logger = config.Logger
|
||||
extract := config.ExtractRefsSequentially
|
||||
idxConfig.ExtractRefsSequentially = extract
|
||||
|
||||
@@ -87,6 +87,9 @@ type SpecIndexConfig struct {
|
||||
// If resolving locally, the BasePath will be the root from which relative references will be resolved from
|
||||
BasePath string // set the Base Path for resolving relative references if the spec is exploded.
|
||||
|
||||
// SpecFilePath is the name of the root specification file (usually named "openapi.yaml").
|
||||
SpecFilePath string
|
||||
|
||||
// In an earlier version of libopenapi (pre 0.6.0) the index would automatically resolve all references
|
||||
// They could have been local, or they could have been remote. This was a problem because it meant
|
||||
// There was a potential for a remote exploit if a remote reference was malicious. There aren't any known
|
||||
|
||||
@@ -312,7 +312,7 @@ func (r *Rolodex) IndexTheRolodex() error {
|
||||
}
|
||||
|
||||
if len(r.localFS) > 0 || len(r.remoteFS) > 0 {
|
||||
r.indexConfig.SpecAbsolutePath = filepath.Join(basePath, "root.yaml")
|
||||
r.indexConfig.SpecAbsolutePath = filepath.Join(basePath, filepath.Base(r.indexConfig.SpecFilePath))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user