@@ -356,57 +356,7 @@ public static OpenApiDocument FixReferences(OpenApiDocument document)
356356
357357 return doc ;
358358 }
359-
360- private static async Task < Stream > GetStream ( string input , ILogger logger )
361- {
362- var stopwatch = new Stopwatch ( ) ;
363- stopwatch . Start ( ) ;
364-
365- Stream stream ;
366- if ( input . StartsWith ( "http" ) )
367- {
368- try
369- {
370- var httpClientHandler = new HttpClientHandler ( )
371- {
372- SslProtocols = System . Security . Authentication . SslProtocols . Tls12 ,
373- } ;
374- using var httpClient = new HttpClient ( httpClientHandler )
375- {
376- DefaultRequestVersion = HttpVersion . Version20
377- } ;
378- stream = await httpClient . GetStreamAsync ( input ) ;
379- }
380- catch ( HttpRequestException ex )
381- {
382- logger . LogError ( $ "Could not download the file at { input } , reason{ ex } ") ;
383- return null ;
384- }
385- }
386- else
387- {
388- try
389- {
390- var fileInput = new FileInfo ( input ) ;
391- stream = fileInput . OpenRead ( ) ;
392- }
393- catch ( Exception ex ) when ( ex is FileNotFoundException ||
394- ex is PathTooLongException ||
395- ex is DirectoryNotFoundException ||
396- ex is IOException ||
397- ex is UnauthorizedAccessException ||
398- ex is SecurityException ||
399- ex is NotSupportedException )
400- {
401- logger . LogError ( $ "Could not open the file at { input } , reason: { ex . Message } ") ;
402- return null ;
403- }
404- }
405- stopwatch . Stop ( ) ;
406- logger . LogTrace ( "{timestamp}ms: Read file {input}" , stopwatch . ElapsedMilliseconds , input ) ;
407- return stream ;
408- }
409-
359+
410360 /// <summary>
411361 /// Takes in a file stream, parses the stream into a JsonDocument and gets a list of paths and Http methods
412362 /// </summary>
@@ -462,34 +412,6 @@ private static Dictionary<string, List<string>> EnumerateJsonDocument(JsonElemen
462412 return paths ;
463413 }
464414
465- /// <summary>
466- /// Fixes the references in the resulting OpenApiDocument.
467- /// </summary>
468- /// <param name="document"> The converted OpenApiDocument.</param>
469- /// <returns> A valid OpenApiDocument instance.</returns>
470- // private static OpenApiDocument FixReferences2(OpenApiDocument document)
471- // {
472- // // This method is only needed because the output of ConvertToOpenApi isn't quite a valid OpenApiDocument instance.
473- // // So we write it out, and read it back in again to fix it up.
474-
475- // OpenApiDocument document;
476- // logger.LogTrace("Parsing the OpenApi file");
477- // var result = await new OpenApiStreamReader(new OpenApiReaderSettings
478- // {
479- // RuleSet = ValidationRuleSet.GetDefaultRuleSet(),
480- // BaseUrl = new Uri(openapi)
481- // }
482- // ).ReadAsync(stream);
483-
484- // document = result.OpenApiDocument;
485- // var context = result.OpenApiDiagnostic;
486- // var sb = new StringBuilder();
487- // document.SerializeAsV3(new OpenApiYamlWriter(new StringWriter(sb)));
488- // var doc = new OpenApiStringReader().Read(sb.ToString(), out _);
489-
490- // return doc;
491- // }
492-
493415 /// <summary>
494416 /// Reads stream from file system or makes HTTP request depending on the input string
495417 /// </summary>
0 commit comments