35
35
36
36
namespace Microsoft . OpenApi . Hidi
37
37
{
38
- internal class OpenApiService
38
+ internal static class OpenApiService
39
39
{
40
40
/// <summary>
41
41
/// Implementation of the transform command
@@ -134,7 +134,7 @@ private static async Task<ApiDependency> FindApiDependency(string apiManifestPat
134
134
{
135
135
apiManifest = ApiManifestDocument . Load ( JsonDocument . Parse ( fileStream ) . RootElement ) ;
136
136
}
137
-
137
+
138
138
apiDependency = apiDependencyName != null ? apiManifest . ApiDependencies [ apiDependencyName ] : apiManifest . ApiDependencies . First ( ) . Value ;
139
139
}
140
140
@@ -146,7 +146,7 @@ private static OpenApiDocument ApplyFilters(HidiOptions options, ILogger logger,
146
146
Dictionary < string , List < string > > requestUrls = null ;
147
147
if ( apiDependency != null )
148
148
{
149
- requestUrls = GetRequestUrlsFromManifest ( apiDependency , document ) ;
149
+ requestUrls = GetRequestUrlsFromManifest ( apiDependency ) ;
150
150
}
151
151
else if ( postmanCollection != null )
152
152
{
@@ -159,7 +159,7 @@ private static OpenApiDocument ApplyFilters(HidiOptions options, ILogger logger,
159
159
options . FilterOptions . FilterByTags ,
160
160
requestUrls ,
161
161
document ,
162
- logger , cancellationToken ) ;
162
+ logger ) ;
163
163
if ( predicate != null )
164
164
{
165
165
var stopwatch = new Stopwatch ( ) ;
@@ -242,7 +242,7 @@ private static async Task<OpenApiDocument> GetOpenApi(string openapi, string csd
242
242
return document ;
243
243
}
244
244
245
- private static Func < string , OperationType ? , OpenApiOperation , bool > FilterOpenApiDocument ( string filterbyoperationids , string filterbytags , Dictionary < string , List < string > > requestUrls , OpenApiDocument document , ILogger logger , CancellationToken cancellationToken )
245
+ private static Func < string , OperationType ? , OpenApiOperation , bool > FilterOpenApiDocument ( string filterbyoperationids , string filterbytags , Dictionary < string , List < string > > requestUrls , OpenApiDocument document , ILogger logger )
246
246
{
247
247
Func < string , OperationType ? , OpenApiOperation , bool > predicate = null ;
248
248
@@ -275,9 +275,9 @@ private static async Task<OpenApiDocument> GetOpenApi(string openapi, string csd
275
275
return predicate ;
276
276
}
277
277
278
- private static Dictionary < string , List < string > > GetRequestUrlsFromManifest ( ApiDependency apiDependency , OpenApiDocument document )
278
+ private static Dictionary < string , List < string > > GetRequestUrlsFromManifest ( ApiDependency apiDependency )
279
279
{
280
- // Get the request URLs from the API Dependencies in the API manifest that have a baseURL that matches the server URL in the OpenAPI document
280
+ // Get the request URLs from the API Dependencies in the API manifest
281
281
var requests = apiDependency
282
282
. Requests . Where ( r => ! r . Exclude )
283
283
. Select ( r=> new { UriTemplate = r . UriTemplate , Method = r . Method } )
@@ -696,18 +696,19 @@ internal static void WriteTreeDocumentAsHtml(string sourceUrl, OpenApiDocument d
696
696
writer . WriteLine ( "</html" ) ;
697
697
}
698
698
699
- internal async static Task PluginManifest ( HidiOptions options , ILogger < OpenApiService > logger , CancellationToken cancellationToken )
699
+ internal async static Task PluginManifest ( HidiOptions options , ILogger logger , CancellationToken cancellationToken )
700
700
{
701
701
// If ApiManifest is provided, set the referenced OpenAPI document
702
702
var apiDependency = await FindApiDependency ( options . FilterOptions ? . FilterByApiManifest , logger , cancellationToken ) ;
703
703
if ( apiDependency != null ) {
704
704
options . OpenApi = apiDependency . ApiDescripionUrl ;
705
705
}
706
706
707
-
708
707
// Load OpenAPI document
709
708
OpenApiDocument document = await GetOpenApi ( options . OpenApi , options . Csdl , options . CsdlFilter , options . SettingsConfig , options . InlineExternal , logger , cancellationToken , options . MetadataVersion ) ;
710
709
710
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
711
+
711
712
if ( options . FilterOptions != null )
712
713
{
713
714
document = ApplyFilters ( options , logger , apiDependency , null , document , cancellationToken ) ;
0 commit comments