diff --git a/datamodel/document_config.go b/datamodel/document_config.go index 2fb7a88a..7f374e4f 100644 --- a/datamodel/document_config.go +++ b/datamodel/document_config.go @@ -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 diff --git a/datamodel/low/v3/create_document.go b/datamodel/low/v3/create_document.go index f9718730..eaf9302c 100644 --- a/datamodel/low/v3/create_document.go +++ b/datamodel/low/v3/create_document.go @@ -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 diff --git a/index/index_model.go b/index/index_model.go index 623262bc..53659e61 100644 --- a/index/index_model.go +++ b/index/index_model.go @@ -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 diff --git a/index/rolodex.go b/index/rolodex.go index 8e1f8c54..3a3450b1 100644 --- a/index/rolodex.go +++ b/index/rolodex.go @@ -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)) } }