7
7
using Microsoft . OpenApi . Exceptions ;
8
8
using Microsoft . OpenApi . Interfaces ;
9
9
using Microsoft . OpenApi . Models ;
10
- using Microsoft . OpenApi . Services ;
11
10
12
11
namespace Microsoft . OpenApi . Services
13
12
{
14
13
/// <summary>
15
14
/// This class is used to walk an OpenApiDocument and convert unresolved references to references to populated objects
16
15
/// </summary>
17
- internal class OpenApiReferenceResolver : OpenApiVisitorBase
16
+ public class OpenApiReferenceResolver : OpenApiVisitorBase
18
17
{
19
18
private OpenApiDocument _currentDocument ;
20
- private bool _resolveRemoteReferences ;
19
+ private readonly bool _resolveRemoteReferences ;
21
20
private List < OpenApiError > _errors = new List < OpenApiError > ( ) ;
22
21
22
+ /// <summary>
23
+ /// Initializes the <see cref="OpenApiReferenceResolver"/> class.
24
+ /// </summary>
23
25
public OpenApiReferenceResolver ( OpenApiDocument currentDocument , bool resolveRemoteReferences = true )
24
26
{
25
27
_currentDocument = currentDocument ;
26
28
_resolveRemoteReferences = resolveRemoteReferences ;
27
29
}
28
30
29
- public IEnumerable < OpenApiError > Errors
30
- {
31
- get
32
- {
33
- return _errors ;
34
- }
35
- }
31
+ /// <summary>
32
+ /// List of errors related to the OpenApiDocument
33
+ /// </summary>
34
+ public IEnumerable < OpenApiError > Errors => _errors ;
36
35
36
+ /// <summary>
37
+ /// Resolves tags in OpenApiDocument
38
+ /// </summary>
39
+ /// <param name="doc"></param>
37
40
public override void Visit ( OpenApiDocument doc )
38
41
{
39
42
if ( doc . Tags != null )
@@ -42,13 +45,22 @@ public override void Visit(OpenApiDocument doc)
42
45
}
43
46
}
44
47
48
+ /// <summary>
49
+ /// Visits the referenceable element in the host document
50
+ /// </summary>
51
+ /// <param name="referenceable">The referenceable element in the doc.</param>
45
52
public override void Visit ( IOpenApiReferenceable referenceable )
46
53
{
47
54
if ( referenceable . Reference != null )
48
55
{
49
56
referenceable . Reference . HostDocument = _currentDocument ;
50
57
}
51
58
}
59
+
60
+ /// <summary>
61
+ /// Resolves references in components
62
+ /// </summary>
63
+ /// <param name="components"></param>
52
64
public override void Visit ( OpenApiComponents components )
53
65
{
54
66
ResolveMap ( components . Parameters ) ;
@@ -62,6 +74,10 @@ public override void Visit(OpenApiComponents components)
62
74
ResolveMap ( components . Headers ) ;
63
75
}
64
76
77
+ /// <summary>
78
+ /// Resolves all references used in callbacks
79
+ /// </summary>
80
+ /// <param name="callbacks"></param>
65
81
public override void Visit ( IDictionary < string , OpenApiCallback > callbacks )
66
82
{
67
83
ResolveMap ( callbacks ) ;
0 commit comments