11
11
using SharpYaml . Serialization ;
12
12
using System . Linq ;
13
13
using Microsoft . OpenApi . Models ;
14
+ using System ;
14
15
15
16
namespace Microsoft . OpenApi . Readers
16
17
{
@@ -26,6 +27,7 @@ public async Task<ReadResult> ReadAsync(Stream input,
26
27
OpenApiReaderSettings settings ,
27
28
CancellationToken cancellationToken = default )
28
29
{
30
+ if ( input is null ) throw new ArgumentNullException ( nameof ( input ) ) ;
29
31
if ( input is MemoryStream memoryStream )
30
32
{
31
33
return Read ( memoryStream , settings ) ;
@@ -43,6 +45,8 @@ public async Task<ReadResult> ReadAsync(Stream input,
43
45
public ReadResult Read ( MemoryStream input ,
44
46
OpenApiReaderSettings settings )
45
47
{
48
+ if ( input is null ) throw new ArgumentNullException ( nameof ( input ) ) ;
49
+ if ( settings is null ) throw new ArgumentNullException ( nameof ( settings ) ) ;
46
50
JsonNode jsonNode ;
47
51
48
52
// Parse the YAML text in the TextReader into a sequence of JsonNodes
@@ -77,6 +81,7 @@ public T ReadFragment<T>(MemoryStream input,
77
81
out OpenApiDiagnostic diagnostic ,
78
82
OpenApiReaderSettings settings = null ) where T : IOpenApiElement
79
83
{
84
+ if ( input is null ) throw new ArgumentNullException ( nameof ( input ) ) ;
80
85
JsonNode jsonNode ;
81
86
82
87
// Parse the YAML
@@ -92,13 +97,13 @@ public T ReadFragment<T>(MemoryStream input,
92
97
return default ;
93
98
}
94
99
95
- return ReadFragment < T > ( jsonNode , version , out diagnostic ) ;
100
+ return ReadFragment < T > ( jsonNode , version , out diagnostic , settings ) ;
96
101
}
97
102
98
103
/// <inheritdoc/>
99
104
public T ReadFragment < T > ( JsonNode input , OpenApiSpecVersion version , out OpenApiDiagnostic diagnostic , OpenApiReaderSettings settings = null ) where T : IOpenApiElement
100
105
{
101
- return OpenApiReaderRegistry . DefaultReader . ReadFragment < T > ( input , version , out diagnostic ) ;
106
+ return OpenApiReaderRegistry . DefaultReader . ReadFragment < T > ( input , version , out diagnostic , settings ) ;
102
107
}
103
108
104
109
/// <summary>
0 commit comments