Skip to content

Commit 763853d

Browse files
committed
commented out skipped code, might need it later.
1 parent dab79dc commit 763853d

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

document_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,3 +1471,19 @@ func TestDocument_Issue418(t *testing.T) {
14711471
assert.Len(t, errs, 0)
14721472
assert.Len(t, m.Model.Index.GetResolver().GetResolvingErrors(), 0)
14731473
}
1474+
1475+
func TestDocument_Issue418_NoFile(t *testing.T) {
1476+
1477+
spec, _ := os.ReadFile("test_specs/nested_files/openapi-issue-418.yaml")
1478+
1479+
doc, err := NewDocumentWithConfiguration(spec, &datamodel.DocumentConfiguration{
1480+
AllowFileReferences: true,
1481+
BasePath: "test_specs/nested_files",
1482+
})
1483+
if err != nil {
1484+
panic(err)
1485+
}
1486+
m, errs := doc.BuildV3Model()
1487+
assert.Len(t, errs, 0)
1488+
assert.Len(t, m.Model.Index.GetResolver().GetResolvingErrors(), 0)
1489+
}

index/find_component.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,20 @@ func (index *SpecIndex) FindComponent(ctx context.Context, componentId string) *
4444

4545
// check if the context has a root index set, if so this is a deep search that has moved through multiple
4646
// indexes and we need to adjust the URI to reflect the location of the root index.
47-
if ctx.Value(RootIndexKey) != nil {
48-
rootIndex := ctx.Value(RootIndexKey).(*SpecIndex)
49-
if rootIndex != nil && rootIndex.specAbsolutePath != "" {
50-
dir := filepath.Dir(rootIndex.specAbsolutePath)
51-
// create an absolute path to the file.
52-
absoluteFilePath := filepath.Join(dir, componentId)
53-
// split into a URI.
54-
uri = []string{absoluteFilePath}
55-
}
56-
}
47+
//
48+
// the below code has been commended out due to being handled in the index. Keeping it for legacy and for
49+
// future bugs.
50+
//
51+
//if ctx.Value(RootIndexKey) != nil {
52+
// rootIndex := ctx.Value(RootIndexKey).(*SpecIndex)
53+
// if rootIndex != nil && rootIndex.specAbsolutePath != "" {
54+
// dir := filepath.Dir(rootIndex.specAbsolutePath)
55+
// // create an absolute path to the file.
56+
// absoluteFilePath := filepath.Join(dir, componentId)
57+
// // split into a URI.
58+
// uri = []string{absoluteFilePath}
59+
// }
60+
//}
5761

5862
return index.lookupRolodex(uri)
5963
}

0 commit comments

Comments
 (0)