1- using System . Collections . Generic ;
1+ // Copyright (c) Microsoft Corporation. All rights reserved.
2+ // Licensed under the MIT license.
3+
4+ using System . Collections . Generic ;
25using Microsoft . OpenApi . Interfaces ;
36using Microsoft . OpenApi . Models ;
47
58namespace Microsoft . OpenApi . Services
69{
710 internal class CopyReferences : OpenApiVisitorBase
811 {
9- private readonly OpenApiDocument target ;
10- public OpenApiComponents Components = new OpenApiComponents ( ) ;
12+ private readonly OpenApiDocument _target ;
13+ public OpenApiComponents Components = new ( ) ;
1114
1215 public CopyReferences ( OpenApiDocument target )
1316 {
14- this . target = target ;
17+ _target = target ;
1518 }
1619
20+ /// <summary>
21+ /// Visits IOpenApiReferenceable instances that are references and not in components.
22+ /// </summary>
23+ /// <param name="referenceable"> An IOpenApiReferenceable object.</param>
1724 public override void Visit ( IOpenApiReferenceable referenceable )
1825 {
1926 switch ( referenceable )
@@ -51,6 +58,10 @@ public override void Visit(IOpenApiReferenceable referenceable)
5158 base . Visit ( referenceable ) ;
5259 }
5360
61+ /// <summary>
62+ /// Visits <see cref="OpenApiSchema"/>
63+ /// </summary>
64+ /// <param name="schema">The OpenApiSchema to be visited.</param>
5465 public override void Visit ( OpenApiSchema schema )
5566 {
5667 // This is needed to handle schemas used in Responses in components
@@ -68,33 +79,33 @@ public override void Visit(OpenApiSchema schema)
6879
6980 private void EnsureComponentsExists ( )
7081 {
71- if ( target . Components == null )
82+ if ( _target . Components == null )
7283 {
73- target . Components = new OpenApiComponents ( ) ;
84+ _target . Components = new OpenApiComponents ( ) ;
7485 }
7586 }
7687
7788 private void EnsureSchemasExists ( )
7889 {
79- if ( target . Components . Schemas == null )
90+ if ( _target . Components . Schemas == null )
8091 {
81- target . Components . Schemas = new Dictionary < string , OpenApiSchema > ( ) ;
92+ _target . Components . Schemas = new Dictionary < string , OpenApiSchema > ( ) ;
8293 }
8394 }
8495
8596 private void EnsureParametersExists ( )
8697 {
87- if ( target . Components . Parameters == null )
98+ if ( _target . Components . Parameters == null )
8899 {
89- target . Components . Parameters = new Dictionary < string , OpenApiParameter > ( ) ;
100+ _target . Components . Parameters = new Dictionary < string , OpenApiParameter > ( ) ;
90101 }
91102 }
92103
93104 private void EnsureResponsesExists ( )
94105 {
95- if ( target . Components . Responses == null )
106+ if ( _target . Components . Responses == null )
96107 {
97- target . Components . Responses = new Dictionary < string , OpenApiResponse > ( ) ;
108+ _target . Components . Responses = new Dictionary < string , OpenApiResponse > ( ) ;
98109 }
99110 }
100111 }
0 commit comments