Skip to content

Commit fd27b29

Browse files
authored
Merge pull request #403 from timbms/rootPath
2 parents 90c137c + 052deec commit fd27b29

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Sources/OpenAPIKitCore/Shared/Path.swift

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ extension Shared {
2828
}
2929

3030
public var rawValue: String {
31+
if components.isEmpty {
32+
return "/"
33+
}
34+
3135
let path =
3236
"/\(components.joined(separator: "/"))"
3337

Tests/OpenAPIKitTests/Path Item/PathItemTests.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ final class PathItemTests: XCTestCase {
1717
let t5: OpenAPI.Path = "hello/world"
1818
let t6: OpenAPI.Path = "hello/world/"
1919
let t7 = OpenAPI.Path(["hello", "world"], trailingSlash: true)
20-
20+
let t8 = OpenAPI.Path(rawValue: "/")
21+
2122
XCTAssertEqual(t1, t2)
2223
XCTAssertEqual(t2, t3)
2324
XCTAssertEqual(t3, t4)
@@ -31,6 +32,7 @@ final class PathItemTests: XCTestCase {
3132
XCTAssertEqual(t4.rawValue, "/hello/world")
3233
XCTAssertEqual(t5.rawValue, "/hello/world")
3334
XCTAssertEqual(t6.rawValue, "/hello/world/")
35+
XCTAssertEqual(t8.rawValue, "/")
3436
}
3537

3638
func test_initializePathItem() {

0 commit comments

Comments
 (0)