77using Microsoft . OpenApi . Exceptions ;
88using Microsoft . OpenApi . Interfaces ;
99using Microsoft . OpenApi . Models ;
10- using Microsoft . OpenApi . Services ;
1110
1211namespace Microsoft . OpenApi . Services
1312{
1413 /// <summary>
1514 /// This class is used to walk an OpenApiDocument and convert unresolved references to references to populated objects
1615 /// </summary>
17- internal class OpenApiReferenceResolver : OpenApiVisitorBase
16+ public class OpenApiReferenceResolver : OpenApiVisitorBase
1817 {
1918 private OpenApiDocument _currentDocument ;
20- private bool _resolveRemoteReferences ;
19+ private readonly bool _resolveRemoteReferences ;
2120 private List < OpenApiError > _errors = new List < OpenApiError > ( ) ;
2221
22+ /// <summary>
23+ /// Initializes the <see cref="OpenApiReferenceResolver"/> class.
24+ /// </summary>
2325 public OpenApiReferenceResolver ( OpenApiDocument currentDocument , bool resolveRemoteReferences = true )
2426 {
2527 _currentDocument = currentDocument ;
2628 _resolveRemoteReferences = resolveRemoteReferences ;
2729 }
2830
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 ;
3635
36+ /// <summary>
37+ /// Resolves tags in OpenApiDocument
38+ /// </summary>
39+ /// <param name="doc"></param>
3740 public override void Visit ( OpenApiDocument doc )
3841 {
3942 if ( doc . Tags != null )
@@ -42,13 +45,22 @@ public override void Visit(OpenApiDocument doc)
4245 }
4346 }
4447
48+ /// <summary>
49+ /// Visits the referenceable element in the host document
50+ /// </summary>
51+ /// <param name="referenceable">The referenceable element in the doc.</param>
4552 public override void Visit ( IOpenApiReferenceable referenceable )
4653 {
4754 if ( referenceable . Reference != null )
4855 {
4956 referenceable . Reference . HostDocument = _currentDocument ;
5057 }
5158 }
59+
60+ /// <summary>
61+ /// Resolves references in components
62+ /// </summary>
63+ /// <param name="components"></param>
5264 public override void Visit ( OpenApiComponents components )
5365 {
5466 ResolveMap ( components . Parameters ) ;
@@ -62,6 +74,10 @@ public override void Visit(OpenApiComponents components)
6274 ResolveMap ( components . Headers ) ;
6375 }
6476
77+ /// <summary>
78+ /// Resolves all references used in callbacks
79+ /// </summary>
80+ /// <param name="callbacks"></param>
6581 public override void Visit ( IDictionary < string , OpenApiCallback > callbacks )
6682 {
6783 ResolveMap ( callbacks ) ;
0 commit comments