@@ -166,31 +166,31 @@ public OpenApiSpecVersion Version
166166 public bool IsYaml
167167 {
168168 get => Format == OpenApiFormat . Yaml ;
169- set => Format = OpenApiFormat . Yaml ;
169+ set => Format = value ? OpenApiFormat . Yaml : Format ;
170170 }
171171
172172 public bool IsJson
173173 {
174174 get => Format == OpenApiFormat . Json ;
175- set => Format = OpenApiFormat . Json ;
175+ set => Format = value ? OpenApiFormat . Json : Format ;
176176 }
177177
178178 public bool IsV2_0
179179 {
180180 get => Version == OpenApiSpecVersion . OpenApi2_0 ;
181- set => Version = OpenApiSpecVersion . OpenApi2_0 ;
181+ set => Version = value ? OpenApiSpecVersion . OpenApi2_0 : Version ;
182182 }
183183
184184 public bool IsV3_0
185185 {
186186 get => Version == OpenApiSpecVersion . OpenApi3_0 ;
187- set => Version = OpenApiSpecVersion . OpenApi3_0 ;
187+ set => Version = value ? OpenApiSpecVersion . OpenApi3_0 : Version ;
188188 }
189189
190190 public bool IsV3_1
191191 {
192192 get => Version == OpenApiSpecVersion . OpenApi3_1 ;
193- set => Version = OpenApiSpecVersion . OpenApi3_1 ;
193+ set => Version = value ? OpenApiSpecVersion . OpenApi3_1 : Version ;
194194 }
195195
196196 /// <summary>
@@ -219,14 +219,8 @@ internal async Task ParseDocumentAsync()
219219 {
220220 if ( ! string . IsNullOrWhiteSpace ( _inputFile ) )
221221 {
222- if ( _inputFile . StartsWith ( "http" ) )
223- {
224- stream = await _httpClient . GetStreamAsync ( _inputFile ) ;
225- }
226- else
227- {
228- stream = new FileStream ( _inputFile , FileMode . Open ) ;
229- }
222+ stream = _inputFile . StartsWith ( "http" ) ? await _httpClient . GetStreamAsync ( _inputFile )
223+ : new FileStream ( _inputFile , FileMode . Open ) ;
230224 }
231225 else
232226 {
@@ -245,16 +239,10 @@ internal async Task ParseDocumentAsync()
245239 ReferenceResolution = ResolveExternal ? ReferenceResolutionSetting . ResolveAllReferences : ReferenceResolutionSetting . ResolveLocalReferences ,
246240 RuleSet = ValidationRuleSet . GetDefaultRuleSet ( )
247241 } ;
248- if ( ResolveExternal )
242+ if ( ResolveExternal && ! string . IsNullOrWhiteSpace ( _inputFile ) )
249243 {
250- if ( _inputFile . StartsWith ( "http" ) )
251- {
252- settings . BaseUrl = new ( _inputFile ) ;
253- }
254- else
255- {
256- settings . BaseUrl = new ( "file://" + Path . GetDirectoryName ( _inputFile ) + "/" ) ;
257- }
244+ settings . BaseUrl = _inputFile . StartsWith ( "http" ) ? new ( _inputFile )
245+ : new ( "file://" + Path . GetDirectoryName ( _inputFile ) + "/" ) ;
258246 }
259247
260248 var readResult = await OpenApiDocument . LoadAsync ( stream , Format . GetDisplayName ( ) ) ;
@@ -305,7 +293,6 @@ internal async Task ParseDocumentAsync()
305293 stream . Close ( ) ;
306294 await stream . DisposeAsync ( ) ;
307295 }
308-
309296 }
310297 }
311298
0 commit comments