File tree Expand file tree Collapse file tree 2 files changed +18
-21
lines changed
src/Microsoft.OpenApi/Services Expand file tree Collapse file tree 2 files changed +18
-21
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ namespace Microsoft.OpenApi.Services
15
15
public abstract class OpenApiVisitorBase
16
16
{
17
17
private readonly Stack < string > _path = new Stack < string > ( ) ;
18
- private bool _inComponents = false ;
19
18
20
19
/// <summary>
21
20
/// Allow Rule to indicate validation error occured at a deeper context level.
@@ -34,16 +33,6 @@ public void Exit()
34
33
this . _path . Pop ( ) ;
35
34
}
36
35
37
- public void EnterComponents ( )
38
- {
39
- _inComponents = true ;
40
- }
41
-
42
- public void ExitComponents ( )
43
- {
44
- _inComponents = false ;
45
- }
46
-
47
36
/// <summary>
48
37
/// Pointer to source of validation error in document
49
38
/// </summary>
@@ -55,13 +44,7 @@ public string PathString
55
44
}
56
45
}
57
46
58
- public bool InComponents
59
- {
60
- get
61
- {
62
- return _inComponents ;
63
- }
64
- }
47
+
65
48
66
49
/// <summary>
67
50
/// Visits <see cref="OpenApiDocument"/>
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ public class OpenApiWalker
18
18
private readonly OpenApiVisitorBase _visitor ;
19
19
private readonly Stack < OpenApiSchema > _schemaLoop = new Stack < OpenApiSchema > ( ) ;
20
20
private readonly Stack < OpenApiPathItem > _pathItemLoop = new Stack < OpenApiPathItem > ( ) ;
21
+ private bool _inComponents = false ;
21
22
22
23
/// <summary>
23
24
/// Initializes the <see cref="OpenApiWalker"/> class.
@@ -37,6 +38,9 @@ public void Walk(OpenApiDocument doc)
37
38
{
38
39
return ;
39
40
}
41
+ _schemaLoop . Clear ( ) ;
42
+ _pathItemLoop . Clear ( ) ;
43
+ _inComponents = false ;
40
44
41
45
_visitor . Visit ( doc ) ;
42
46
@@ -96,7 +100,7 @@ internal void Walk(OpenApiComponents components)
96
100
return ;
97
101
}
98
102
99
- _visitor . EnterComponents ( ) ;
103
+ EnterComponents ( ) ;
100
104
101
105
_visitor . Visit ( components ) ;
102
106
@@ -194,7 +198,7 @@ internal void Walk(OpenApiComponents components)
194
198
} ) ;
195
199
196
200
Walk ( components as IOpenApiExtensible ) ;
197
- _visitor . ExitComponents ( ) ;
201
+ ExitComponents ( ) ;
198
202
}
199
203
200
204
/// <summary>
@@ -1027,7 +1031,17 @@ private void Walk(string context, Action walk)
1027
1031
/// </summary>
1028
1032
private bool IsReference ( IOpenApiReferenceable referenceable )
1029
1033
{
1030
- return referenceable . Reference != null && ! _visitor . InComponents ;
1034
+ return referenceable . Reference != null && ! _inComponents ;
1035
+ }
1036
+
1037
+ private void EnterComponents ( )
1038
+ {
1039
+ _inComponents = true ;
1040
+ }
1041
+
1042
+ private void ExitComponents ( )
1043
+ {
1044
+ _inComponents = false ;
1031
1045
}
1032
1046
}
1033
1047
}
You can’t perform that action at this time.
0 commit comments