Skip to content

Adopt SE-409 #134

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

Closed
wants to merge 3 commits into from
Closed
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
12 changes: 9 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@
import PackageDescription

// General Swift-settings for all targets.
let swiftSettings: [SwiftSetting] = [
// https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md
// Require `any` for existential types.
var swiftSettings: [SwiftSetting] = [
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0335-existential-any.md
.enableUpcomingFeature("ExistentialAny")
]
#if compiler(>=6.0)
swiftSettings.append(contentsOf: [
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0409-access-level-on-imports.md
.enableUpcomingFeature("InternalImportsByDefault"),
.enableExperimentalFeature("AccessLevelOnImport"),
])
#endif

let package = Package(
name: "swift-openapi-runtime",
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIRuntime/Base/UndocumentedPayload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

import HTTPTypes
public import HTTPTypes

/// A payload value used by undocumented operation responses.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIRuntime/Conversion/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
public import Foundation

/// A type that allows customization of Date encoding and decoding.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIRuntime/Conversion/Converter+Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
import Foundation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this API breaking? You were previously importing Foundation as public but with the changed flag it is now imported as internal. Since imports are leaky in Swift this would be API breaking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module still publicly imports Foundation, just in other files. So the module as a whole doesn't remove the public import.

But it's kind of moot - seems for packages that still need to support 5.x, making both 5.x and 6.x compilers warning free with explicit access modifiers on imports would require a ton of #if guards, so I'm punting on this for now.

import HTTPTypes
public import HTTPTypes

extension Converter {

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIRuntime/Conversion/Converter+Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
import Foundation
import HTTPTypes
public import HTTPTypes

extension Converter {

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIRuntime/Conversion/Converter+Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
import Foundation
import HTTPTypes
public import HTTPTypes

extension Converter {

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIRuntime/Conversion/ServerVariable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

import Foundation
public import Foundation

extension URL {
/// Returns a validated server URL created from the URL template, or
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIRuntime/Conversion/URLExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
public import Foundation

extension URL {
/// Returns the default server URL of "/".
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIRuntime/Deprecated/Deprecated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
public import Foundation
import HTTPTypes

// MARK: - Functionality to be removed in the future
Expand Down
8 changes: 4 additions & 4 deletions Sources/OpenAPIRuntime/Errors/ClientError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
//
//===----------------------------------------------------------------------===//

import HTTPTypes
public import HTTPTypes
#if canImport(Darwin)
import struct Foundation.URL
public import struct Foundation.URL
#else
@preconcurrency import struct Foundation.URL
@preconcurrency public import struct Foundation.URL
#endif
import protocol Foundation.LocalizedError
public import protocol Foundation.LocalizedError

/// An error thrown by a client performing an OpenAPI operation.
///
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenAPIRuntime/Errors/ServerError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
//
//===----------------------------------------------------------------------===//

import HTTPTypes
import protocol Foundation.LocalizedError
public import HTTPTypes
public import protocol Foundation.LocalizedError

/// An error thrown by a server handling an OpenAPI operation.
public struct ServerError: Error {
Expand Down
6 changes: 3 additions & 3 deletions Sources/OpenAPIRuntime/EventStreams/JSONLinesDecoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
//===----------------------------------------------------------------------===//

#if canImport(Darwin)
import class Foundation.JSONDecoder
public import class Foundation.JSONDecoder
#else
@preconcurrency import class Foundation.JSONDecoder
@preconcurrency public import class Foundation.JSONDecoder
#endif
import struct Foundation.Data
public import struct Foundation.Data

/// A sequence that parses arbitrary byte chunks into lines using the JSON Lines format.
public struct JSONLinesDeserializationSequence<Upstream: AsyncSequence & Sendable>: Sendable
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenAPIRuntime/EventStreams/JSONLinesEncoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
//===----------------------------------------------------------------------===//

#if canImport(Darwin)
import class Foundation.JSONEncoder
public import class Foundation.JSONEncoder
#else
@preconcurrency import class Foundation.JSONEncoder
@preconcurrency public import class Foundation.JSONEncoder
#endif

/// A sequence that serializes lines by concatenating them using the JSON Lines format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
//===----------------------------------------------------------------------===//

#if canImport(Darwin)
import class Foundation.JSONDecoder
public import class Foundation.JSONDecoder
#else
@preconcurrency import class Foundation.JSONDecoder
@preconcurrency public import class Foundation.JSONDecoder
#endif
import protocol Foundation.LocalizedError
import struct Foundation.Data
public import protocol Foundation.LocalizedError
public import struct Foundation.Data

/// A sequence that parses arbitrary byte chunks into lines using the JSON Sequence format.
public struct JSONSequenceDeserializationSequence<Upstream: AsyncSequence & Sendable>: Sendable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
//===----------------------------------------------------------------------===//

#if canImport(Darwin)
import class Foundation.JSONEncoder
public import class Foundation.JSONEncoder
#else
@preconcurrency import class Foundation.JSONEncoder
@preconcurrency public import class Foundation.JSONEncoder
#endif

/// A sequence that serializes lines by concatenating them using the JSON Sequence format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
//===----------------------------------------------------------------------===//

#if canImport(Darwin)
import class Foundation.JSONDecoder
public import class Foundation.JSONDecoder
#else
@preconcurrency import class Foundation.JSONDecoder
@preconcurrency public import class Foundation.JSONDecoder
#endif
import struct Foundation.Data
public import struct Foundation.Data

/// A sequence that parses arbitrary byte chunks into events using the Server-sent Events format.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
//===----------------------------------------------------------------------===//

#if canImport(Darwin)
import class Foundation.JSONEncoder
public import class Foundation.JSONEncoder
#else
@preconcurrency import class Foundation.JSONEncoder
@preconcurrency public import class Foundation.JSONEncoder
#endif

/// A sequence that serializes Server-sent Events.
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenAPIRuntime/Interface/ClientTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
//
//===----------------------------------------------------------------------===//

import HTTPTypes
import struct Foundation.URL
public import HTTPTypes
public import struct Foundation.URL

/// A type that performs HTTP operations.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIRuntime/Interface/CurrencyTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

import HTTPTypes
public import HTTPTypes

/// A container for request metadata already parsed and validated
/// by the server transport.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

import HTTPTypes
public import HTTPTypes

/// An opt-in error handling middleware that converts an error to an HTTP response.
///
Expand Down
6 changes: 3 additions & 3 deletions Sources/OpenAPIRuntime/Interface/HTTPBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
//
//===----------------------------------------------------------------------===//

import class Foundation.NSLock
import protocol Foundation.LocalizedError
import struct Foundation.Data // only for convenience initializers
public import class Foundation.NSLock
public import protocol Foundation.LocalizedError
public import struct Foundation.Data // only for convenience initializers

/// A body of an HTTP request or HTTP response.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIRuntime/Interface/ServerTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

import HTTPTypes
public import HTTPTypes

/// A type that registers and handles HTTP operations.
///
Expand Down
6 changes: 3 additions & 3 deletions Sources/OpenAPIRuntime/Interface/UniversalClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import HTTPTypes
public import HTTPTypes
#if canImport(Darwin)
import struct Foundation.URL
public import struct Foundation.URL
#else
@preconcurrency import struct Foundation.URL
@preconcurrency public import struct Foundation.URL
#endif

/// OpenAPI document-agnostic HTTP client used by OpenAPI document-specific,
Expand Down
8 changes: 4 additions & 4 deletions Sources/OpenAPIRuntime/Interface/UniversalServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
//
//===----------------------------------------------------------------------===//

import HTTPTypes
public import HTTPTypes
#if canImport(Darwin)
import struct Foundation.URL
public import struct Foundation.URL
#else
@preconcurrency import struct Foundation.URL
@preconcurrency public import struct Foundation.URL
#endif
import struct Foundation.URLComponents
public import struct Foundation.URLComponents

/// OpenAPI document-agnostic HTTP server used by OpenAPI document-specific,
/// generated servers to perform request deserialization, middleware and handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

import Foundation
import HTTPTypes
public import HTTPTypes

/// A raw multipart part containing the header fields and the body stream.
public struct MultipartRawPart: Sendable, Hashable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

import Foundation
import HTTPTypes
public import HTTPTypes

// MARK: - Extensions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ final class Test_ClientConverterExtensions: Test_Runtime {
/// - message: An optional custom message to display upon test failure.
/// - file: The file name to include in the failure message (default is the source file where this function is called).
/// - line: The line number to include in the failure message (default is the line where this function is called).
public func XCTAssertEqualStringifiedData(
func XCTAssertEqualStringifiedData(
_ expression1: @autoclosure () throws -> Data,
_ expression2: @autoclosure () throws -> String,
_ message: @autoclosure () -> String = "",
Expand Down
6 changes: 3 additions & 3 deletions Tests/OpenAPIRuntimeTests/Test_Runtime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ struct MockCustomCoder: CustomCoder {
/// - rhs: The expected absolute string representation.
/// - file: The file name to include in the failure message (default is the source file where this function is called).
/// - line: The line number to include in the failure message (default is the line where this function is called).
public func XCTAssertEqualURLString(_ lhs: URL?, _ rhs: String, file: StaticString = #filePath, line: UInt = #line) {
func XCTAssertEqualURLString(_ lhs: URL?, _ rhs: String, file: StaticString = #filePath, line: UInt = #line) {
guard let lhs else {
XCTFail("URL is nil")
return
Expand Down Expand Up @@ -384,7 +384,7 @@ public func XCTAssertEqualStringifiedData<S: Sequence>(
/// - file: The file name to include in the failure message (default is the source file where this function is called).
/// - line: The line number to include in the failure message (default is the line where this function is called).
/// - Throws: If either of the autoclosures throws an error, the function will rethrow that error.
public func XCTAssertEqualStringifiedData(
func XCTAssertEqualStringifiedData(
_ expression1: @autoclosure () throws -> HTTPBody?,
_ expression2: @autoclosure () throws -> String,
_ message: @autoclosure () -> String = "",
Expand Down Expand Up @@ -474,7 +474,7 @@ public func XCTAssertEqualAsyncData<C: Collection, AS: AsyncSequence>(
}

/// Asserts that the data matches the expected value.
public func XCTAssertEqualData<C: Collection>(
func XCTAssertEqualData<C: Collection>(
_ expression1: @autoclosure () throws -> HTTPBody?,
_ expression2: @autoclosure () throws -> C,
_ message: @autoclosure () -> String = "Data doesn't match.",
Expand Down
Loading