@@ -39,21 +39,32 @@ internal async Task<OpenApiDiagnostic> LoadAsync(OpenApiReference reference,
39
39
// Walk references
40
40
foreach ( var item in referenceCollector . References )
41
41
{
42
+
42
43
// If not already in workspace, load it and process references
43
44
if ( ! _workspace . Contains ( item . ExternalResource ) )
44
45
{
45
- var input = await _loader . LoadAsync ( new ( item . ExternalResource , UriKind . RelativeOrAbsolute ) ) ;
46
- var result = await OpenApiDocument . LoadAsync ( input , format , _readerSettings , cancellationToken ) ;
47
- // Merge diagnostics
48
- if ( result . OpenApiDiagnostic != null )
46
+ if ( ! Guid . TryParse ( item . ExternalResource , out _ ) )
49
47
{
50
- diagnostic . AppendDiagnostic ( result . OpenApiDiagnostic , item . ExternalResource ) ;
48
+ var input = await _loader . LoadAsync ( new ( item . ExternalResource , UriKind . RelativeOrAbsolute ) ) ;
49
+ var result = await OpenApiDocument . LoadAsync ( input , format , _readerSettings , cancellationToken ) ;
50
+ // Merge diagnostics
51
+ if ( result . OpenApiDiagnostic != null )
52
+ {
53
+ diagnostic . AppendDiagnostic ( result . OpenApiDiagnostic , item . ExternalResource ) ;
54
+ }
55
+ if ( result . OpenApiDocument != null )
56
+ {
57
+ var loadDiagnostic = await LoadAsync ( item , result . OpenApiDocument , format , diagnostic , cancellationToken ) ;
58
+ diagnostic = loadDiagnostic ;
59
+ }
51
60
}
52
- if ( result . OpenApiDocument != null )
61
+ else // local ref in an external file, add this to the documents registry
53
62
{
54
- var loadDiagnostic = await LoadAsync ( item , result . OpenApiDocument , format , diagnostic , cancellationToken ) ;
55
- diagnostic = loadDiagnostic ;
56
- }
63
+ if ( ! _workspace . Contains ( item . ExternalResource ) )
64
+ {
65
+ _workspace . AddDocument ( reference . ExternalResource , document ) ;
66
+ }
67
+ }
57
68
}
58
69
}
59
70
0 commit comments