Uh oh!
There was an error while loading. Please reload this page.
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.
Vincent Biret (baywet)
commented
Mar 12, 2025
Thanks for the contribution! Maggie Kimani (@MaggieKimani1) can you do an initial review here please? |
Uh oh!
There was an error while loading. Please reload this page.
dldl-cmd sorry for the delay in response/review. Once you do so, the files will automatically be registered with the source document's workspace. Reference: |
Maggie Kimani (@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.yamlWhen the reference This information is not only necessary at the time of loading the document but also when |
Maggie Kimani (MaggieKimani1)
commented
Apr 1, 2025
Also do you mind resolving the conflicts? |
Uh oh!
There was an error while loading. Please reload this page.
dldl-cmd
commented
Apr 7, 2025
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
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