-
Notifications
You must be signed in to change notification settings - Fork 279
Description
Is your feature request related to a problem? Please describe.
I am using the Readers to parse OpenApi contracts. I have an OpenApi contract that references an external file. It turned out this external file has an error, but the ReturnResult I get has no diagnostics in, I stepped through the code and I can see where it fails, but the diagnostics gets lost, it seems to be in here (see snippet below) in the code, and I noticed that possibly this problem has come up before since there is a comment // TODO merge _diagnositics:
internal class OpenApiWorkspaceLoader
{
.....
internal async Task LoadAsync(OpenApiReference reference, OpenApiDocument document)
{
_workspace.AddDocument(reference.ExternalResource, document);
document.Workspace = _workspace;
// Collect remote references by walking document
var referenceCollector = new OpenApiRemoteReferenceCollector(document);
var collectorWalker = new OpenApiWalker(referenceCollector);
collectorWalker.Walk(document);
var reader = new OpenApiStreamReader(_readerSettings);
// Walk references
foreach (var item in referenceCollector.References)
{
// If not already in workspace, load it and process references
if (!_workspace.Contains(item.ExternalResource))
{
var input = await _loader.LoadAsync(new Uri(item.ExternalResource, UriKind.RelativeOrAbsolute));
var result = await reader.ReadAsync(input); // TODO merge _diagnositics
await LoadAsync(item, result.OpenApiDocument);
}
}
}
}
Describe the solution you'd like
I would love to get the diagnostics. Our Use Case is that we analyze and validate the OpenApi contract for the user and if there is an error we would like to give them a usable report that tells them what they should fix in the main document as well as any external references.
Describe alternatives you've considered
I thought of implementing something here myself, but there seems to be a slight change of structure required because the OpenApiWorkspaceLoader.LoadAsync() seems to be recursive and the diagnostic is thrown away on each recursion because there is nowhere to store it to pass it back up, for example perhaps make it part of the OpenApiDocument, or another result wrapper that can pass both on in the recursion. But I do not want to break things because I am unfamiliar with this library.
So I am wondering what the chances are somebody will be able to do this, or tell me what to do then I can help out and implement, because it will really be great for us to have.