@@ -27,7 +27,7 @@ public class OpenApiJsonReader : IOpenApiReader
2727 /// <param name="settings">The Reader settings to be used during parsing.</param>
2828 /// <returns></returns>
2929 public ReadResult Read ( MemoryStream input ,
30- OpenApiReaderSettings settings = null )
30+ OpenApiReaderSettings settings )
3131 {
3232 JsonNode jsonNode ;
3333 var diagnostic = new OpenApiDiagnostic ( ) ;
@@ -51,40 +51,6 @@ public ReadResult Read(MemoryStream input,
5151 return Read ( jsonNode , settings ) ;
5252 }
5353
54-
55- /// <summary>
56- /// Reads the stream input asynchronously and parses it into an Open API document.
57- /// </summary>
58- /// <param name="input">TextReader containing OpenAPI description to parse.</param>
59- /// <param name="settings">The Reader settings to be used during parsing.</param>
60- /// <param name="cancellationToken">Propagates notifications that operations should be cancelled.</param>
61- /// <returns></returns>
62- public async Task < ReadResult > ReadAsync ( Stream input ,
63- OpenApiReaderSettings settings ,
64- CancellationToken cancellationToken = default )
65- {
66- JsonNode jsonNode ;
67- var diagnostic = new OpenApiDiagnostic ( ) ;
68- settings ??= new OpenApiReaderSettings ( ) ;
69-
70- // Parse the JSON text in the TextReader into JsonNodes
71- try
72- {
73- jsonNode = await JsonNode . ParseAsync ( input ) ;
74- }
75- catch ( JsonException ex )
76- {
77- diagnostic . Errors . Add ( new OpenApiError ( $ "#line={ ex . LineNumber } ", $ "Please provide the correct format, { ex . Message } ") ) ;
78- return new ReadResult
79- {
80- OpenApiDocument = null ,
81- OpenApiDiagnostic = diagnostic
82- } ;
83- }
84-
85- return Read ( jsonNode , settings ) ;
86- }
87-
8854 /// <summary>
8955 /// Parses the JsonNode input into an Open API document.
9056 /// </summary>
@@ -137,6 +103,39 @@ public ReadResult Read(JsonNode jsonNode,
137103 } ;
138104 }
139105
106+ /// <summary>
107+ /// Reads the stream input asynchronously and parses it into an Open API document.
108+ /// </summary>
109+ /// <param name="input">TextReader containing OpenAPI description to parse.</param>
110+ /// <param name="settings">The Reader settings to be used during parsing.</param>
111+ /// <param name="cancellationToken">Propagates notifications that operations should be cancelled.</param>
112+ /// <returns></returns>
113+ public async Task < ReadResult > ReadAsync ( Stream input ,
114+ OpenApiReaderSettings settings ,
115+ CancellationToken cancellationToken = default )
116+ {
117+ JsonNode jsonNode ;
118+ var diagnostic = new OpenApiDiagnostic ( ) ;
119+ settings ??= new OpenApiReaderSettings ( ) ;
120+
121+ // Parse the JSON text in the TextReader into JsonNodes
122+ try
123+ {
124+ jsonNode = await JsonNode . ParseAsync ( input ) ;
125+ }
126+ catch ( JsonException ex )
127+ {
128+ diagnostic . Errors . Add ( new OpenApiError ( $ "#line={ ex . LineNumber } ", $ "Please provide the correct format, { ex . Message } ") ) ;
129+ return new ReadResult
130+ {
131+ OpenApiDocument = null ,
132+ OpenApiDiagnostic = diagnostic
133+ } ;
134+ }
135+
136+ return Read ( jsonNode , settings ) ;
137+ }
138+
140139 /// <inheritdoc/>
141140 public T ReadFragment < T > ( MemoryStream input ,
142141 OpenApiSpecVersion version ,
0 commit comments