-
Notifications
You must be signed in to change notification settings - Fork 252
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
Fix: relative references in subdirectory documents are not loading #1674 #2243
Fix: relative references in subdirectory documents are not loading #1674 #2243
Conversation
…crosoft#1674 Use OpenApiDocuments BaseUri as location of the document. This allows to have during loading further documents a base Url for retrieval, which can be combined with a relative Uri to get an absolute.
Thanks for the contribution! @MaggieKimani1 can you do an initial review here please? |
@dldl-cmd sorry for the delay in response/review. Line 53 in ff287bc
Once you do so, the files will automatically be registered with the source document's workspace. Reference: Lines 85 to 98 in ff287bc
|
@MaggieKimani1 implementing just an own stream loader cannot solve the problem. The reason is, that the stream loader has no idea, which document is the current parent and where this document is located. Therefore it cannot resolve the relative reference as it doesn't know to which location it is relative. An example:
....
$ref: ./DirA/DirB/DirC/second.yaml#/components/schema/Second
...
$ref: ../third.yaml#/components/schema/Third
...
$ref: ./DirC/Fourth.yaml#/components/schema/Fourth.yaml When the reference This information is not only necessary at the time of loading the document but also when |
Also do you mind resolving the conflicts? |
Sorry for my late reply, I was unavailable a few days. I didn't notice the merge conflict until now. I have started to resolve them, but I need to check at least one conflict more in detail. Hopefully I can resolve it in the next days. |
(_, true, false) when baseUrl.Scheme.Equals("file", StringComparison.OrdinalIgnoreCase) && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows) => | ||
new Uri(Path.Combine(baseUrl.AbsoluteUri, uri.ToString())), | ||
(_, _, _) => new Uri(baseUrl, uri), | ||
true => new Uri(Path.Combine(Directory.GetCurrentDirectory(), uri.ToString())), |
Check notice
Code scanning / CodeQL
Call to System.IO.Path.Combine Note
Use OpenApiDocuments BaseUri as location of the document. This allows to have during loading further documents a base Url for retrieval, which can be combined with a relative Uri to get an absolute.
Fixes #1674