1
- // Copyright (c) Microsoft Corporation. All rights reserved.
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT license.
3
3
4
4
using System . Collections . Generic ;
@@ -9,14 +9,18 @@ namespace Microsoft.OpenApi.Services
9
9
{
10
10
internal class CopyReferences : OpenApiVisitorBase
11
11
{
12
- private readonly OpenApiDocument target ;
13
- public OpenApiComponents Components = new OpenApiComponents ( ) ;
12
+ private readonly OpenApiDocument _target ;
13
+ public OpenApiComponents Components = new ( ) ;
14
14
15
15
public CopyReferences ( OpenApiDocument target )
16
16
{
17
- this . target = target ;
17
+ _target = target ;
18
18
}
19
19
20
+ /// <summary>
21
+ /// Visits IOpenApiReferenceable instances that are references and not in components.
22
+ /// </summary>
23
+ /// <param name="referenceable"> An IOpenApiReferenceable object.</param>
20
24
public override void Visit ( IOpenApiReferenceable referenceable )
21
25
{
22
26
switch ( referenceable )
@@ -54,6 +58,10 @@ public override void Visit(IOpenApiReferenceable referenceable)
54
58
base . Visit ( referenceable ) ;
55
59
}
56
60
61
+ /// <summary>
62
+ /// Visits <see cref="OpenApiSchema"/>
63
+ /// </summary>
64
+ /// <param name="schema">The OpenApiSchema to be visited.</param>
57
65
public override void Visit ( OpenApiSchema schema )
58
66
{
59
67
// This is needed to handle schemas used in Responses in components
@@ -71,33 +79,33 @@ public override void Visit(OpenApiSchema schema)
71
79
72
80
private void EnsureComponentsExists ( )
73
81
{
74
- if ( target . Components == null )
82
+ if ( _target . Components == null )
75
83
{
76
- target . Components = new OpenApiComponents ( ) ;
84
+ _target . Components = new OpenApiComponents ( ) ;
77
85
}
78
86
}
79
87
80
88
private void EnsureSchemasExists ( )
81
89
{
82
- if ( target . Components . Schemas == null )
90
+ if ( _target . Components . Schemas == null )
83
91
{
84
- target . Components . Schemas = new Dictionary < string , OpenApiSchema > ( ) ;
92
+ _target . Components . Schemas = new Dictionary < string , OpenApiSchema > ( ) ;
85
93
}
86
94
}
87
95
88
96
private void EnsureParametersExists ( )
89
97
{
90
- if ( target . Components . Parameters == null )
98
+ if ( _target . Components . Parameters == null )
91
99
{
92
- target . Components . Parameters = new Dictionary < string , OpenApiParameter > ( ) ;
100
+ _target . Components . Parameters = new Dictionary < string , OpenApiParameter > ( ) ;
93
101
}
94
102
}
95
103
96
104
private void EnsureResponsesExists ( )
97
105
{
98
- if ( target . Components . Responses == null )
106
+ if ( _target . Components . Responses == null )
99
107
{
100
- target . Components . Responses = new Dictionary < string , OpenApiResponse > ( ) ;
108
+ _target . Components . Responses = new Dictionary < string , OpenApiResponse > ( ) ;
101
109
}
102
110
}
103
111
}
0 commit comments