Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
adrianhj opened this issue Feb 1, 2023 · 0 comments
Assignees

Comments

@adrianhj
Copy link
Contributor

adrianhj commented Feb 1, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants