File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
test/Microsoft.OpenApi.Tests/Validations Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT license.
3
+
4
+ using System . Collections . Generic ;
5
+ using Microsoft . OpenApi . Models ;
6
+ using Microsoft . OpenApi . Validations ;
7
+ using Xunit ;
8
+
9
+ namespace Microsoft . OpenApi . Tests . Models
10
+ {
11
+ public class OpenApiExternalDocsValidationTests
12
+ {
13
+ [ Fact ]
14
+ public void ValidateUrlIsRequiredInExternalDocs ( )
15
+ {
16
+ // Arrange
17
+ IEnumerable < ValidationError > errors ;
18
+ OpenApiExternalDocs externalDocs = new OpenApiExternalDocs ( ) ;
19
+
20
+ // Act
21
+ bool result = externalDocs . Validate ( out errors ) ;
22
+
23
+ // Assert
24
+ Assert . False ( result ) ;
25
+ Assert . NotNull ( errors ) ;
26
+ ValidationError error = Assert . Single ( errors ) ;
27
+ Assert . Equal ( "The field 'url' in 'External Documentation' object is REQUIRED." , error . ErrorMessage ) ;
28
+ }
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT license.
3
+
4
+ using System . Collections . Generic ;
5
+ using Microsoft . OpenApi . Models ;
6
+ using Microsoft . OpenApi . Validations ;
7
+ using Xunit ;
8
+
9
+ namespace Microsoft . OpenApi . Tests . Models
10
+ {
11
+ public class OpenApiResponseValidationTests
12
+ {
13
+ [ Fact ]
14
+ public void ValidateDescriptionIsRequiredInResponse ( )
15
+ {
16
+ // Arrange
17
+ IEnumerable < ValidationError > errors ;
18
+ OpenApiResponse response = new OpenApiResponse ( ) ;
19
+
20
+ // Act
21
+ bool result = response . Validate ( out errors ) ;
22
+
23
+ // Assert
24
+ Assert . False ( result ) ;
25
+ Assert . NotNull ( errors ) ;
26
+ ValidationError error = Assert . Single ( errors ) ;
27
+ Assert . Equal ( "The field 'description' in 'response' object is REQUIRED." , error . ErrorMessage ) ;
28
+ }
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments