@@ -67,26 +67,29 @@ public static class OpenApiFilterService
67
67
{
68
68
var operationTypes = new List < string > ( ) ;
69
69
70
- var apiVersion = source . Info . Version ;
71
-
72
- var sources = new Dictionary < string , OpenApiDocument > { { apiVersion , source } } ;
73
- var rootNode = CreateOpenApiUrlTreeNode ( sources ) ;
74
-
75
- //Iterate through urls dictionary and fetch operations for each url
76
- foreach ( var path in requestUrls )
70
+ if ( source != null )
77
71
{
78
- var serverList = source . Servers ;
79
- var url = FormatUrlString ( path . Key , serverList ) ;
72
+ var apiVersion = source . Info . Version ;
80
73
81
- var openApiOperations = GetOpenApiOperations ( rootNode , url , apiVersion ) ;
82
- if ( openApiOperations == null )
83
- {
84
- continue ;
85
- }
74
+ var sources = new Dictionary < string , OpenApiDocument > { { apiVersion , source } } ;
75
+ var rootNode = CreateOpenApiUrlTreeNode ( sources ) ;
86
76
87
- foreach ( var ops in openApiOperations )
77
+ //Iterate through urls dictionary and fetch operations for each url
78
+ foreach ( var path in requestUrls )
88
79
{
89
- operationTypes . Add ( ops . Key + url ) ;
80
+ var serverList = source . Servers ;
81
+ var url = FormatUrlString ( path . Key , serverList ) ;
82
+
83
+ var openApiOperations = GetOpenApiOperations ( rootNode , url , apiVersion ) ;
84
+ if ( openApiOperations == null )
85
+ {
86
+ continue ;
87
+ }
88
+
89
+ foreach ( var ops in openApiOperations )
90
+ {
91
+ operationTypes . Add ( ops . Key + url ) ;
92
+ }
90
93
}
91
94
}
92
95
@@ -199,10 +202,8 @@ public static Dictionary<string, List<string>> ParseJsonCollectionFile(Stream st
199
202
using var document = JsonDocument . Parse ( stream ) ;
200
203
var root = document . RootElement ;
201
204
var itemElement = root . GetProperty ( "item" ) ;
202
- foreach ( JsonElement item in itemElement . EnumerateArray ( ) )
205
+ foreach ( var requestObject in itemElement . EnumerateArray ( ) . Select ( item => item . GetProperty ( "request" ) ) )
203
206
{
204
- var requestObject = item . GetProperty ( "request" ) ;
205
-
206
207
// Fetch list of methods and urls from collection, store them in a dictionary
207
208
var path = requestObject . GetProperty ( "url" ) . GetProperty ( "raw" ) . ToString ( ) ;
208
209
var method = requestObject . GetProperty ( "method" ) . ToString ( ) ;
0 commit comments