1111using SharpYaml . Serialization ;
1212using System . Linq ;
1313using Microsoft . OpenApi . Models ;
14+ using System ;
1415
1516namespace Microsoft . OpenApi . Readers
1617{
@@ -26,6 +27,7 @@ public async Task<ReadResult> ReadAsync(Stream input,
2627 OpenApiReaderSettings settings ,
2728 CancellationToken cancellationToken = default )
2829 {
30+ if ( input is null ) throw new ArgumentNullException ( nameof ( input ) ) ;
2931 if ( input is MemoryStream memoryStream )
3032 {
3133 return Read ( memoryStream , settings ) ;
@@ -43,6 +45,8 @@ public async Task<ReadResult> ReadAsync(Stream input,
4345 public ReadResult Read ( MemoryStream input ,
4446 OpenApiReaderSettings settings )
4547 {
48+ if ( input is null ) throw new ArgumentNullException ( nameof ( input ) ) ;
49+ if ( settings is null ) throw new ArgumentNullException ( nameof ( settings ) ) ;
4650 JsonNode jsonNode ;
4751
4852 // Parse the YAML text in the TextReader into a sequence of JsonNodes
@@ -77,6 +81,7 @@ public T ReadFragment<T>(MemoryStream input,
7781 out OpenApiDiagnostic diagnostic ,
7882 OpenApiReaderSettings settings = null ) where T : IOpenApiElement
7983 {
84+ if ( input is null ) throw new ArgumentNullException ( nameof ( input ) ) ;
8085 JsonNode jsonNode ;
8186
8287 // Parse the YAML
@@ -92,13 +97,13 @@ public T ReadFragment<T>(MemoryStream input,
9297 return default ;
9398 }
9499
95- return ReadFragment < T > ( jsonNode , version , out diagnostic ) ;
100+ return ReadFragment < T > ( jsonNode , version , out diagnostic , settings ) ;
96101 }
97102
98103 /// <inheritdoc/>
99104 public T ReadFragment < T > ( JsonNode input , OpenApiSpecVersion version , out OpenApiDiagnostic diagnostic , OpenApiReaderSettings settings = null ) where T : IOpenApiElement
100105 {
101- return OpenApiReaderRegistry . DefaultReader . ReadFragment < T > ( input , version , out diagnostic ) ;
106+ return OpenApiReaderRegistry . DefaultReader . ReadFragment < T > ( input , version , out diagnostic , settings ) ;
102107 }
103108
104109 /// <summary>
0 commit comments