From d110a0223bc6b96bda213175f51a4fbb9a131491 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 18 Sep 2024 08:15:25 -0400 Subject: [PATCH 01/11] Fixing issue with Swift 6.0 and Date Format --- .github/workflows/tests.yml | 8 ++++++++ Sources/OpenAPIReflection/Date+OpenAPI.swift | 2 ++ Sources/OpenAPIReflection30/Date+OpenAPI.swift | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c02465c..e414d21 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,6 +20,14 @@ jobs: - swift:5.9-focal - swift:5.9-jammy - swift:5.9-amazonlinux2 + - swift:5.10-focal + - swift:5.10-jammy + - swift:5.10-noble + - swift:5.10-amazonlinux2 + - swift:6.0-focal + - swift:6.0-jammy + - swift:6.0-noble + - swift:6.0-amazonlinux2 container: ${{ matrix.image }} steps: - name: Checkout code diff --git a/Sources/OpenAPIReflection/Date+OpenAPI.swift b/Sources/OpenAPIReflection/Date+OpenAPI.swift index cd2d864..a178224 100644 --- a/Sources/OpenAPIReflection/Date+OpenAPI.swift +++ b/Sources/OpenAPIReflection/Date+OpenAPI.swift @@ -25,11 +25,13 @@ extension Date: DateOpenAPISchemaType { case .iso8601: return .string(format: .dateTime) + #if !canImport(FoundationEssentials) || swift(<5.10) case .formatted(let formatter): let hasTime = formatter.timeStyle != .none let format: JSONTypeFormat.StringFormat = hasTime ? .dateTime : .date return .string(format: format) + #endif @unknown default: return nil diff --git a/Sources/OpenAPIReflection30/Date+OpenAPI.swift b/Sources/OpenAPIReflection30/Date+OpenAPI.swift index f105362..7e72052 100644 --- a/Sources/OpenAPIReflection30/Date+OpenAPI.swift +++ b/Sources/OpenAPIReflection30/Date+OpenAPI.swift @@ -8,6 +8,8 @@ import Foundation import OpenAPIKit30 + + extension Date: DateOpenAPISchemaType { public static func dateOpenAPISchemaGuess(using encoder: JSONEncoder) -> JSONSchema? { @@ -25,11 +27,13 @@ extension Date: DateOpenAPISchemaType { case .iso8601: return .string(format: .dateTime) + #if !canImport(FoundationEssentials) || swift(<5.10) case .formatted(let formatter): let hasTime = formatter.timeStyle != .none let format: JSONTypeFormat.StringFormat = hasTime ? .dateTime : .date return .string(format: format) + #endif @unknown default: return nil From 59f39e4c12340e9768bfba0e93db30862cc4bbb9 Mon Sep 17 00:00:00 2001 From: leogdion Date: Wed, 18 Sep 2024 08:18:54 -0400 Subject: [PATCH 02/11] Update Date+OpenAPI.swift removing white space --- Sources/OpenAPIReflection30/Date+OpenAPI.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/OpenAPIReflection30/Date+OpenAPI.swift b/Sources/OpenAPIReflection30/Date+OpenAPI.swift index 7e72052..2832d63 100644 --- a/Sources/OpenAPIReflection30/Date+OpenAPI.swift +++ b/Sources/OpenAPIReflection30/Date+OpenAPI.swift @@ -8,8 +8,6 @@ import Foundation import OpenAPIKit30 - - extension Date: DateOpenAPISchemaType { public static func dateOpenAPISchemaGuess(using encoder: JSONEncoder) -> JSONSchema? { From bdfeea47a1613537ca692ca5f5785cfb8a7f084a Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 18 Sep 2024 08:20:05 -0400 Subject: [PATCH 03/11] Run Github Workflows --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e414d21..b86756a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,7 +4,7 @@ on: pull_request: push: branches: - - master + - main jobs: linux: From 5f454df05f6612b2a9a7d7c0787c15eaada4777b Mon Sep 17 00:00:00 2001 From: leogdion Date: Wed, 18 Sep 2024 08:24:34 -0400 Subject: [PATCH 04/11] Update tests.yml --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b86756a..2dbc3c7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,7 +31,7 @@ jobs: container: ${{ matrix.image }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run tests run: swift test --enable-test-discovery osx: @@ -41,6 +41,6 @@ jobs: uses: maxim-lobanov/setup-xcode@v1 with: { 'xcode-version': 'latest' } - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run tests run: swift test --enable-test-discovery From 1e30d9609574ef522b31abf8d818eeb2364f7caf Mon Sep 17 00:00:00 2001 From: leogdion Date: Wed, 18 Sep 2024 08:29:46 -0400 Subject: [PATCH 05/11] Update tests.yml --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2dbc3c7..3dd9498 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,7 +28,8 @@ jobs: - swift:6.0-jammy - swift:6.0-noble - swift:6.0-amazonlinux2 - container: ${{ matrix.image }} + container: + image: ${{ matrix.image }} steps: - name: Checkout code uses: actions/checkout@v4 From 52b8adec9f73892a5e6166e87c80feff2969ae8a Mon Sep 17 00:00:00 2001 From: leogdion Date: Wed, 18 Sep 2024 08:31:36 -0400 Subject: [PATCH 06/11] Update tests.yml --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3dd9498..3f9ae0f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,7 +32,7 @@ jobs: image: ${{ matrix.image }} steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Run tests run: swift test --enable-test-discovery osx: @@ -42,6 +42,6 @@ jobs: uses: maxim-lobanov/setup-xcode@v1 with: { 'xcode-version': 'latest' } - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Run tests run: swift test --enable-test-discovery From f5716325994080bedfbafe0f17d5ed60777d970d Mon Sep 17 00:00:00 2001 From: leogdion Date: Wed, 18 Sep 2024 09:45:36 -0400 Subject: [PATCH 07/11] Update tests.yml --- .github/workflows/tests.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3f9ae0f..63a14f4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,21 +13,16 @@ jobs: fail-fast: false matrix: image: - - swift:5.8-bionic - swift:5.8-focal - swift:5.8-jammy - - swift:5.8-amazonlinux2 - swift:5.9-focal - swift:5.9-jammy - - swift:5.9-amazonlinux2 - swift:5.10-focal - swift:5.10-jammy - swift:5.10-noble - - swift:5.10-amazonlinux2 - swift:6.0-focal - swift:6.0-jammy - swift:6.0-noble - - swift:6.0-amazonlinux2 container: image: ${{ matrix.image }} steps: From 2f714a197d21cf773eaaa40cef9b9cc2173adc3a Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Tue, 24 Sep 2024 10:23:48 -0400 Subject: [PATCH 08/11] fixing tests with skip --- .../GenericOpenAPISchemaTests.swift | 84 ++++++++++--------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift b/Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift index 07e6c56..273052a 100644 --- a/Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift +++ b/Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift @@ -102,46 +102,50 @@ final class GenericOpenAPISchemaTests: XCTestCase { let node3 = try DateType.genericOpenAPISchemaGuess(using: e3) XCTAssertEqual(node2, node3) - XCTAssertEqual( - node2, - JSONSchema.object( - properties: [ - "date": .number(format: .double) - ] - ) - ) - - let e4 = JSONEncoder() - let df1 = DateFormatter() - df1.timeStyle = .none - e4.dateEncodingStrategy = .formatted(df1) - - let node4 = try DateType.genericOpenAPISchemaGuess(using: e4) - - XCTAssertEqual( - node4, - JSONSchema.object( - properties: [ - "date": .string(format: .date) - ] - ) - ) - - let e5 = JSONEncoder() - let df2 = DateFormatter() - df2.timeStyle = .full - e5.dateEncodingStrategy = .formatted(df2) - - let node5 = try DateType.genericOpenAPISchemaGuess(using: e5) - - XCTAssertEqual( - node5, - JSONSchema.object( - properties: [ - "date": .string(format: .dateTime) - ] - ) - ) + #if os(Linux) + throw XCTSkip("Not supported on Linux.") + #else + XCTAssertEqual( + node2, + JSONSchema.object( + properties: [ + "date": .number(format: .double) + ] + ) + ) + + let e4 = JSONEncoder() + let df1 = DateFormatter() + df1.timeStyle = .none + e4.dateEncodingStrategy = .formatted(df1) + + let node4 = try DateType.genericOpenAPISchemaGuess(using: e4) + + XCTAssertEqual( + node4, + JSONSchema.object( + properties: [ + "date": .string(format: .date) + ] + ) + ) + + let e5 = JSONEncoder() + let df2 = DateFormatter() + df2.timeStyle = .full + e5.dateEncodingStrategy = .formatted(df2) + + let node5 = try DateType.genericOpenAPISchemaGuess(using: e5) + + XCTAssertEqual( + node5, + JSONSchema.object( + properties: [ + "date": .string(format: .dateTime) + ] + ) + ) + #endif } func test_nested() throws { From 391d08cd2bb52b9f42ed54c286863aac8795afc8 Mon Sep 17 00:00:00 2001 From: leogdion Date: Tue, 24 Sep 2024 10:35:55 -0400 Subject: [PATCH 09/11] Update GenericOpenAPISchemaTests.swift --- .../OpenAPIReflection30Tests/GenericOpenAPISchemaTests.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tests/OpenAPIReflection30Tests/GenericOpenAPISchemaTests.swift b/Tests/OpenAPIReflection30Tests/GenericOpenAPISchemaTests.swift index cc0c9f1..6921c6a 100644 --- a/Tests/OpenAPIReflection30Tests/GenericOpenAPISchemaTests.swift +++ b/Tests/OpenAPIReflection30Tests/GenericOpenAPISchemaTests.swift @@ -98,7 +98,9 @@ final class GenericOpenAPISchemaTests: XCTestCase { let df1 = DateFormatter() df1.timeStyle = .none e4.dateEncodingStrategy = .formatted(df1) - + #if os(Linux) + throw XCTSkip("Not supported on Linux.") + #else let node4 = try DateType.genericOpenAPISchemaGuess(using: e4) XCTAssertEqual( @@ -125,6 +127,7 @@ final class GenericOpenAPISchemaTests: XCTestCase { ] ) ) + #endif } func test_nested() throws { From 971265d3e5eb4232fa1d9b409224eaf0bae296aa Mon Sep 17 00:00:00 2001 From: leogdion Date: Tue, 24 Sep 2024 10:39:40 -0400 Subject: [PATCH 10/11] Update GenericOpenAPISchemaTests.swift --- .../GenericOpenAPISchemaTests.swift | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift b/Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift index 273052a..54deab4 100644 --- a/Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift +++ b/Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift @@ -103,49 +103,49 @@ final class GenericOpenAPISchemaTests: XCTestCase { XCTAssertEqual(node2, node3) #if os(Linux) - throw XCTSkip("Not supported on Linux.") + throw XCTSkip("Not supported on Linux.") #else - XCTAssertEqual( - node2, - JSONSchema.object( - properties: [ - "date": .number(format: .double) - ] - ) - ) - - let e4 = JSONEncoder() - let df1 = DateFormatter() - df1.timeStyle = .none - e4.dateEncodingStrategy = .formatted(df1) - - let node4 = try DateType.genericOpenAPISchemaGuess(using: e4) - - XCTAssertEqual( - node4, - JSONSchema.object( - properties: [ - "date": .string(format: .date) - ] - ) - ) - - let e5 = JSONEncoder() - let df2 = DateFormatter() - df2.timeStyle = .full - e5.dateEncodingStrategy = .formatted(df2) - - let node5 = try DateType.genericOpenAPISchemaGuess(using: e5) - - XCTAssertEqual( - node5, - JSONSchema.object( - properties: [ - "date": .string(format: .dateTime) - ] - ) - ) - #endif + XCTAssertEqual( + node2, + JSONSchema.object( + properties: [ + "date": .number(format: .double) + ] + ) + ) + + let e4 = JSONEncoder() + let df1 = DateFormatter() + df1.timeStyle = .none + e4.dateEncodingStrategy = .formatted(df1) + + let node4 = try DateType.genericOpenAPISchemaGuess(using: e4) + + XCTAssertEqual( + node4, + JSONSchema.object( + properties: [ + "date": .string(format: .date) + ] + ) + ) + + let e5 = JSONEncoder() + let df2 = DateFormatter() + df2.timeStyle = .full + e5.dateEncodingStrategy = .formatted(df2) + + let node5 = try DateType.genericOpenAPISchemaGuess(using: e5) + + XCTAssertEqual( + node5, + JSONSchema.object( + properties: [ + "date": .string(format: .dateTime) + ] + ) + ) + #endif } func test_nested() throws { From ae3dea620a4af9f7642b27c5853f2d661939f911 Mon Sep 17 00:00:00 2001 From: Mathew Polzin Date: Tue, 1 Oct 2024 09:59:27 -0500 Subject: [PATCH 11/11] target exactly the situation for which the tests can't be run --- .../OpenAPIReflection30Tests/GenericOpenAPISchemaTests.swift | 4 ++-- Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/OpenAPIReflection30Tests/GenericOpenAPISchemaTests.swift b/Tests/OpenAPIReflection30Tests/GenericOpenAPISchemaTests.swift index 6921c6a..e027e44 100644 --- a/Tests/OpenAPIReflection30Tests/GenericOpenAPISchemaTests.swift +++ b/Tests/OpenAPIReflection30Tests/GenericOpenAPISchemaTests.swift @@ -98,8 +98,8 @@ final class GenericOpenAPISchemaTests: XCTestCase { let df1 = DateFormatter() df1.timeStyle = .none e4.dateEncodingStrategy = .formatted(df1) - #if os(Linux) - throw XCTSkip("Not supported on Linux.") + #if canImport(FoundationEssentials) && swift(>=5.10) + throw XCTSkip("Not supported for Swift 5.10+ on Linux.") #else let node4 = try DateType.genericOpenAPISchemaGuess(using: e4) diff --git a/Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift b/Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift index 54deab4..8719188 100644 --- a/Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift +++ b/Tests/OpenAPIReflectionTests/GenericOpenAPISchemaTests.swift @@ -102,8 +102,8 @@ final class GenericOpenAPISchemaTests: XCTestCase { let node3 = try DateType.genericOpenAPISchemaGuess(using: e3) XCTAssertEqual(node2, node3) - #if os(Linux) - throw XCTSkip("Not supported on Linux.") + #if canImport(FoundationEssentials) && swift(>=5.10) + throw XCTSkip("Not supported for Swift 5.10+ on Linux.") #else XCTAssertEqual( node2,