File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
test/Microsoft.OpenApi.Readers.Tests/V3Tests Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 99using System . Threading ;
1010using FluentAssertions ;
1111using Microsoft . OpenApi . Any ;
12+ using Microsoft . OpenApi . Exceptions ;
1213using Microsoft . OpenApi . Interfaces ;
1314using Microsoft . OpenApi . Models ;
15+ using Microsoft . OpenApi . Readers . Interface ;
1416using Microsoft . OpenApi . Validations ;
1517using Microsoft . OpenApi . Validations . Rules ;
1618using Microsoft . OpenApi . Writers ;
@@ -1355,5 +1357,15 @@ public void ValidateExampleShouldNotHaveDataTypeMismatch()
13551357 var warnings = diagnostic . Warnings ;
13561358 Assert . False ( warnings . Any ( ) ) ;
13571359 }
1360+
1361+ [ Fact ]
1362+ public void ParseDocumetWithWrongReferenceTypeShouldReturnADiagnosticError ( )
1363+ {
1364+ using var stream = Resources . GetStream ( Path . Combine ( SampleFolderPath , "docWithWrongRef.json" ) ) ;
1365+ _ = new OpenApiStreamReader ( ) . Read ( stream , out var diagnostic ) ;
1366+
1367+ diagnostic . Errors . Should ( ) . BeEquivalentTo ( new List < OpenApiError > {
1368+ new ( new OpenApiException ( "Invalid Reference Type 'Schema'." ) ) } ) ;
1369+ }
13581370 }
13591371}
Original file line number Diff line number Diff line change 1+ {
2+ "openapi" :" 3.0.0" ,
3+ "info" :{
4+ "title" :" some api" ,
5+ "description" :" some description" ,
6+ "version" : " 1"
7+ },
8+ "servers" :[{"url" :" https://localhost" }],
9+ "paths" :{
10+ "/count" :{
11+ "get" :{
12+ "responses" :{
13+ "200" :{
14+ "$ref" :" #/components/schemas/count"
15+ },
16+ },
17+ }
18+ }
19+ },
20+ "components" :{
21+ "schemas" :{
22+ "count" :{
23+ "type" : " number"
24+ }
25+ }
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments