77using BenchmarkDotNet . Attributes ;
88using Microsoft . OpenApi ;
99using Microsoft . OpenApi . Models ;
10- using Microsoft . OpenApi . Reader ;
10+ using Microsoft . OpenApi . Readers ;
1111
1212namespace performance ;
1313
@@ -24,7 +24,7 @@ public async Task<OpenApiDocument> PetStoreYaml()
2424 [ Benchmark ]
2525 public async Task < OpenApiDocument > PetStoreJson ( )
2626 {
27- return await ParseDocumentAsync ( PetStoreJsonPath , OpenApiConstants . Json ) ;
27+ return await ParseDocumentAsync ( PetStoreJsonPath ) ;
2828 }
2929 [ Benchmark ]
3030 public async Task < OpenApiDocument > GHESYaml ( )
@@ -34,7 +34,7 @@ public async Task<OpenApiDocument> GHESYaml()
3434 [ Benchmark ]
3535 public async Task < OpenApiDocument > GHESJson ( )
3636 {
37- return await ParseDocumentAsync ( GHESJsonDescriptionUrl , OpenApiConstants . Json ) ;
37+ return await ParseDocumentAsync ( GHESJsonDescriptionUrl ) ;
3838 }
3939 private readonly Dictionary < string , MemoryStream > _streams = new ( StringComparer . OrdinalIgnoreCase ) ;
4040 [ GlobalSetup ]
@@ -45,7 +45,6 @@ public async Task GetAllDescriptions()
4545 {
4646 LeaveStreamOpen = true ,
4747 } ;
48- readerSettings . AddYamlReader ( ) ;
4948 await LoadDocumentFromAssemblyIntoStreams ( PetStoreYamlPath ) ;
5049 await LoadDocumentFromAssemblyIntoStreams ( PetStoreJsonPath ) ;
5150 await LoadDocumentFromUrlIntoStreams ( GHESYamlDescriptionUrl ) ;
@@ -56,14 +55,14 @@ public async Task GetAllDescriptions()
5655 private const string PetStoreJsonPath = @"petStore.json" ;
5756 private const string GHESYamlDescriptionUrl = @"https://raw.githubusercontent.com/github/rest-api-description/aef5e31a2d10fdaab311ec6d18a453021a81383d/descriptions/ghes-3.16/ghes-3.16.2022-11-28.yaml" ;
5857 private const string GHESJsonDescriptionUrl = @"https://raw.githubusercontent.com/github/rest-api-description/aef5e31a2d10fdaab311ec6d18a453021a81383d/descriptions/ghes-3.16/ghes-3.16.2022-11-28.json" ;
59- private async Task < OpenApiDocument > ParseDocumentAsync ( string fileName , string format = null )
58+ private async Task < OpenApiDocument > ParseDocumentAsync ( string fileName )
6059 {
61- format ??= OpenApiConstants . Yaml ;
6260 var stream = _streams [ fileName ] ;
6361 stream . Seek ( 0 , SeekOrigin . Begin ) ;
62+ var reader = new OpenApiStreamReader ( readerSettings ) ;
6463
65- var ( document , _ ) = await OpenApiDocument . LoadAsync ( stream , format , readerSettings ) . ConfigureAwait ( false ) ;
66- return document ;
64+ var result = await reader . ReadAsync ( stream ) . ConfigureAwait ( false ) ;
65+ return result . OpenApiDocument ;
6766 }
6867 private HttpClient _httpClient ;
6968 private async Task LoadDocumentFromUrlIntoStreams ( string url )
0 commit comments