Skip to content

Add support for Windows #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
windows_6_0_enabled: true
windows_nightly_6_1_enabled: true
windows_nightly_main_enabled: true
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_6_1_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

integration-test:
name: Integration test
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ jobs:
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
windows_6_0_enabled: true
windows_nightly_6_1_enabled: true
windows_nightly_main_enabled: true
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_6_1_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

integration-test:
name: Integration test
Expand Down
6 changes: 6 additions & 0 deletions Sources/OpenAPIRuntime/Base/OpenAPIValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import class Foundation.NSNull
@preconcurrency import class Foundation.NSNull
#endif
import class Foundation.NSNumber
#if canImport(CoreFoundation)
import CoreFoundation
#endif
#endif

/// A container for a value represented by JSON Schema.
///
Expand Down Expand Up @@ -141,11 +143,13 @@ public struct OpenAPIValueContainer: Codable, Hashable, Sendable {
try container.encodeNil()
return
}
#if canImport(CoreFoundation)
if let nsNumber = value as? NSNumber {
try encode(nsNumber, to: &container)
return
}
#endif
#endif
switch value {
case let value as Bool: try container.encode(value)
case let value as Int: try container.encode(value)
Expand All @@ -162,6 +166,7 @@ public struct OpenAPIValueContainer: Codable, Hashable, Sendable {
)
}
}
#if canImport(CoreFoundation)
/// Encodes the provided NSNumber based on its internal representation.
/// - Parameters:
/// - value: The NSNumber that boxes one of possibly many different types of values.
Expand Down Expand Up @@ -198,6 +203,7 @@ public struct OpenAPIValueContainer: Codable, Hashable, Sendable {
}
}
}
#endif

// MARK: Equatable

Expand Down
2 changes: 2 additions & 0 deletions Tests/OpenAPIRuntimeTests/Base/Test_OpenAPIValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ final class Test_OpenAPIValue: Test_Runtime {
try _testPrettyEncoded(container, expectedJSON: expectedString)
}

#if canImport(CoreFoundation)
func testEncodingNSNumber() throws {
func assertEncodedCF(
_ value: CFNumber,
Expand Down Expand Up @@ -129,6 +130,7 @@ final class Test_OpenAPIValue: Test_Runtime {
XCTAssertThrowsError(try assertEncodedCF(kCFNumberPositiveInfinity, as: "-"))
}
#endif
#endif
func testEncoding_container_failure() throws {
struct Foobar: Equatable {}
XCTAssertThrowsError(try OpenAPIValueContainer(unvalidatedValue: Foobar())) { error in
Expand Down