Skip to content

Classpath loader receives invalid file paths for external references under Windows #1878

Closed

Description

@adrianhj

We are currently in the process of providing a set of common/shared schemas through JAR dependencies and relying on the ability of resolving $ref pointers to these on the classpath.

With a reference such as $ref: "/sdk/openapi/common.yaml#/some/schema" running under platforms utilising / as the path separator all is OK and the files are correctly resolved and read.

When running under platforms utilising \ as the path separator (i.e. Windows), the location to ClasspathHelper.loadFileFromClasspath receives the file to retrieve from the classpath as \sdk\openapi\common.yaml and fails to perform the look-up.

Tracing through the code the issue seems to begin within ExternalRefParser.processRefToExternalSchema where the parsing into a Path converts the separators into \.

When the code ultimately ends up hitting RefUtils.readExternalRef, the incorrect path is used to attempt to retrieve it from the classpath.

My understanding of the classpath is that it expects / separated paths, as per e.g. the JavaDoc for ClassLoader.getResource():

The name of a resource is a '/'-separated path name that identifies the resource.

Activity

  1. added a commit that references this issue on Feb 29, 2024
    7e7123d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions