-
Notifications
You must be signed in to change notification settings - Fork 531
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
Relative $refs fail on Windows due to potential issue in ExternalRefProcessor#processRefToExternalSchema #1886
Comments
By:
Are you relying on $ref's pointing to items on the classpath where it breaks? Sounds very similar to what I have in #1878 (+ somewhat of a fix in #1879) i.e. Path with backslashes after Paths.get(..) is fine when attempting to locate via the Windows filesystem, but once it attempts to retrieve via the classpath will always fail. |
I am loading from the filesystem, not from the classpath.
Yes, but it will also fail to determine the parent folder the next time (when resolved references contain other references) the statement ( At least for me the following patch using
|
This issue impacts other open source project (see Backbase/backbase-openapi-tools#600) |
Hi,
I have some $ref references in my OpenApi specification that work fine on Linux, but fail on Windows.
The problem seems to be in
ExternalRefProcessor#processRefToExternalSchema
(https://github.com/swagger-api/swagger-parser/blob/master/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/ExternalRefProcessor.java#L127) within the following code:In the first line the parent folder is determined by cutting the path at the last forward slash.
"openapi/schemas/model.yaml" = > "openapi/schemas"
But the later Paths.get invocation will replace any forward slashes to backslashes on Windows.
Paths.get("openapi/schemas", "ref.yaml").normalize().toString() => "openapi\schemas\ref.yaml"
The replaced path with backslashes seems to then be used for any further embedded references.
So even when I am only using forward slashes in my openapi files, the call to Paths.get will mess up the $ref resolution eventually.
Proposal:
Replace the backslashes with forward slashes after Paths.get is used or make the parent folder determination platform idependent.
The text was updated successfully, but these errors were encountered: