mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 04:20:11 +00:00
Set indexConfig.SpecAbsolutePath to "root.yaml" (theoretical root) when the spec's root does not exist on the filesystem (either read from remote URL or []byte)
This commit is contained in:
@@ -38,6 +38,7 @@ func TestBundleDocument_DigitalOcean(t *testing.T) {
|
||||
digi, _ := os.ReadFile(spec)
|
||||
|
||||
doc, err := libopenapi.NewDocumentWithConfiguration([]byte(digi), &datamodel.DocumentConfiguration{
|
||||
SpecFilePath: spec,
|
||||
BasePath: tmp + "/specification",
|
||||
ExtractRefsSequentially: true,
|
||||
Logger: slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
|
||||
|
||||
@@ -313,7 +313,13 @@ func (r *Rolodex) IndexTheRolodex() error {
|
||||
}
|
||||
|
||||
if len(r.localFS) > 0 || len(r.remoteFS) > 0 {
|
||||
r.indexConfig.SpecAbsolutePath = filepath.Join(basePath, filepath.Base(r.indexConfig.SpecFilePath))
|
||||
// For specs that are not read from a filesystem (either from remote URL or []byte), we need to
|
||||
// assign a theoretical root file. Having a root file is necessary when mapping references.
|
||||
rootFile := "root.yaml"
|
||||
if r.indexConfig.SpecFilePath != "" {
|
||||
rootFile = filepath.Base(r.indexConfig.SpecFilePath)
|
||||
}
|
||||
r.indexConfig.SpecAbsolutePath = filepath.Join(basePath, rootFile)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user