File tree 4 files changed +50
-3
lines changed
OpenAPIKit30ErrorReportingTests
OpenAPIKit30Tests/Validator 4 files changed +50
-3
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ final class DocumentErrorTests: XCTestCase {
26
26
let openAPIError = OpenAPI . Error ( from: error)
27
27
28
28
XCTAssertEqual ( openAPIError. localizedDescription, " Expected to find `openapi` key in the root Document object but it is missing. " )
29
+ XCTAssertEqual ( openAPIError. localizedDescription, openAPIError. description)
29
30
XCTAssertEqual ( openAPIError. codingPath. map { $0. stringValue } , [ ] )
30
31
}
31
32
}
Original file line number Diff line number Diff line change @@ -1444,6 +1444,12 @@ final class ValidatorTests: XCTestCase {
1444
1444
" Inconsistency encountered when parsing ``: \' gzip \' could not be parsed as a Content Type. Content Types should have the format \' <type>/<subtype> \' . "
1445
1445
)
1446
1446
XCTAssertEqual ( warnings. first? . codingPathString, " .paths[ \' /test \' ].get.responses.200.content " )
1447
+ XCTAssertNotNil ( warnings. first? . underlyingError)
1448
+ XCTAssertNotNil ( warnings. first? . errorCategory)
1449
+ XCTAssertEqual ( warnings. first? . subjectName, " " )
1450
+ XCTAssertEqual ( warnings. first? . contextString, " " )
1451
+
1452
+ XCTAssertEqual ( warnings. first? . localizedDescription, warnings. first? . description)
1447
1453
}
1448
1454
1449
1455
func test_collectsContentTypeWarningStrict( ) throws {
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import OpenAPIKitCore
9
9
import XCTest
10
10
11
11
final class CallbackURLTests : XCTestCase {
12
- func testInit ( ) {
12
+ func test_init ( ) {
13
13
let plainUrl = Shared . CallbackURL ( url: URL ( string: " https://hello.com " ) !)
14
14
XCTAssertEqual ( plainUrl. url, URL ( string: " https://hello.com " ) !)
15
15
XCTAssertEqual ( plainUrl. template. variables. count, 0 )
@@ -19,7 +19,7 @@ final class CallbackURLTests: XCTestCase {
19
19
XCTAssertEqual ( templateUrl? . template. variables, [ " $request.path.id " ] )
20
20
}
21
21
22
- func testEncode ( ) throws {
22
+ func test_encode ( ) throws {
23
23
let url = Shared . CallbackURL ( rawValue: " https://hello.com/item/{$request.path.id} " )
24
24
25
25
let result = try orderUnstableTestStringFromEncoding ( of: url)
@@ -32,7 +32,7 @@ final class CallbackURLTests: XCTestCase {
32
32
)
33
33
}
34
34
35
- func testDecode ( ) throws {
35
+ func test_decode ( ) throws {
36
36
let json = #""https://hello.com/item/{$request.path.id}""#
37
37
let data = json. data ( using: . utf8) !
38
38
Original file line number Diff line number Diff line change
1
+ //
2
+ // ComponentKeyTests.swift
3
+ // OpenAPIKit
4
+ //
5
+ // Created by Mathew Polzin on 2/16/25.
6
+ //
7
+
8
+ import OpenAPIKitCore
9
+ import XCTest
10
+
11
+ final class ComponentKeyTests : XCTestCase {
12
+ func test_init( ) throws {
13
+ let t1 : Shared . ComponentKey = " abcd "
14
+ XCTAssertEqual ( t1. rawValue, " abcd " )
15
+
16
+ let t2 = Shared . ComponentKey ( rawValue: " abcd " )
17
+ XCTAssertEqual ( t2? . rawValue, " abcd " )
18
+
19
+ let t3 = Shared . ComponentKey ( rawValue: " " )
20
+ XCTAssertNil ( t3)
21
+
22
+ let t4 = Shared . ComponentKey ( rawValue: " (abcd) " )
23
+ XCTAssertNil ( t4)
24
+
25
+ let t5 = try Shared . ComponentKey. forceInit ( rawValue: " abcd " )
26
+ XCTAssertEqual ( t5. rawValue, " abcd " )
27
+
28
+ XCTAssertThrowsError ( try Shared . ComponentKey. forceInit ( rawValue: nil ) )
29
+ XCTAssertThrowsError ( try Shared . ComponentKey. forceInit ( rawValue: " (abcd) " ) )
30
+ }
31
+
32
+ func test_problemString( ) {
33
+ let message = Shared . ComponentKey. problem ( with: " (abcd) " )
34
+
35
+ XCTAssertEqual ( message, " Keys for components in the Components Object must conform to the regex `^[a-zA-Z0-9 \\ . \\ -_]+$`. '(abcd)' does not.. " )
36
+
37
+ let nonProblem = Shared . ComponentKey. problem ( with: " abcd " )
38
+ XCTAssertNil ( nonProblem)
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments