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 9
9
using System . Threading ;
10
10
using FluentAssertions ;
11
11
using Microsoft . OpenApi . Any ;
12
+ using Microsoft . OpenApi . Exceptions ;
12
13
using Microsoft . OpenApi . Interfaces ;
13
14
using Microsoft . OpenApi . Models ;
15
+ using Microsoft . OpenApi . Readers . Interface ;
14
16
using Microsoft . OpenApi . Validations ;
15
17
using Microsoft . OpenApi . Validations . Rules ;
16
18
using Microsoft . OpenApi . Writers ;
@@ -1355,5 +1357,15 @@ public void ValidateExampleShouldNotHaveDataTypeMismatch()
1355
1357
var warnings = diagnostic . Warnings ;
1356
1358
Assert . False ( warnings . Any ( ) ) ;
1357
1359
}
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
+ }
1358
1370
}
1359
1371
}
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