Skip to content

Resolving reference error happens with directories of different depths #402

@stakme

Description

@stakme

Hi. I found the recursive lookup will fail when there are files in directories of different depths.

reporduce: https://github.com/stakme/kin-openapi/commit/cefedea2d71ad4ce07f2739ecbaea4c4f113f9cd

> go test github.com/getkin/kin-openapi/openapi3
--- FAIL: TestLoaderReadFromURIFunc (0.00s)
    loader_read_from_uri_func_test.go:20: 
                Error Trace:    loader_read_from_uri_func_test.go:20
                Error:          Received unexpected error:
                                error resolving reference "../openapi.yml#/components/schemas/Bar": open testdata/recursiveRef/components/openapi.yml: no such file or directory
                Test:           TestLoaderReadFromURIFunc
--- FAIL: TestLoaderSupportsRecursiveReference (0.00s)
    loader_recursive_ref_test.go:13: 
                Error Trace:    loader_recursive_ref_test.go:13
                Error:          Received unexpected error:
                                error resolving reference "../openapi.yml#/components/schemas/Bar": open testdata/recursiveRef/components/openapi.yml: no such file or directory
                Test:           TestLoaderSupportsRecursiveReference
FAIL
FAIL    github.com/getkin/kin-openapi/openapi3  0.192s
FAIL

It seems that, each time it resolve the reference, it needs to update the documentPath.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions