Skip to content

Commit aceadfd

Browse files
authored
Enable documentation comment validation in swift-format (#18)
### Motivation - Relates to apple/swift-openapi-generator#165 ### Modifications - Enable new rules in swift-format and address changes required ### Result - New swift format rules will be implemented ### Test Plan - Run the tests
1 parent e270e29 commit aceadfd

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

.swift-format

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"prioritizeKeepingFunctionOutputTogether" : false,
1717
"respectsExistingLineBreaks" : true,
1818
"rules" : {
19-
"AllPublicDeclarationsHaveDocumentation" : false,
19+
"AllPublicDeclarationsHaveDocumentation" : true,
2020
"AlwaysUseLowerCamelCase" : false,
2121
"AmbiguousTrailingClosureOverload" : true,
2222
"BeginDocumentationCommentWithOneLineSummary" : false,
@@ -50,7 +50,7 @@
5050
"UseSynthesizedInitializer" : true,
5151
"UseTripleSlashForDocumentationComments" : true,
5252
"UseWhereClausesInForLoops" : false,
53-
"ValidateDocumentationComments" : false
53+
"ValidateDocumentationComments" : true
5454
},
5555
"spacesAroundRangeFormationOperators" : false,
5656
"tabWidth" : 8,

Sources/OpenAPIURLSession/URLSessionTransport.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ public struct URLSessionTransport: ClientTransport {
7272
public var session: URLSession
7373

7474
/// Creates a new configuration with the provided session.
75-
/// - Parameters:
76-
/// - session: The URLSession used for performing HTTP operations.
75+
/// - Parameter session: The URLSession used for performing HTTP operations.
7776
/// If none is provided, the system uses the shared URLSession.
7877
public init(session: URLSession = .shared) {
7978
self.session = session
@@ -84,12 +83,20 @@ public struct URLSessionTransport: ClientTransport {
8483
public var configuration: Configuration
8584

8685
/// Creates a new URLSession-based transport.
87-
/// - Parameters:
88-
/// - configuration: A set of configuration values used by the transport.
86+
/// - Parameter configuration: A set of configuration values used by the transport.
8987
public init(configuration: Configuration = .init()) {
9088
self.configuration = configuration
9189
}
9290

91+
/// Asynchronously sends an HTTP request and returns the response and body.
92+
///
93+
/// - Parameters:
94+
/// - request: The HTTP request to be sent.
95+
/// - body: The HTTP body to include in the request (optional).
96+
/// - baseURL: The base URL for the request.
97+
/// - operationID: An optional identifier for the operation or request.
98+
/// - Returns: A tuple containing the HTTP response and an optional HTTP response body.
99+
/// - Throws: An error if there is a problem sending the request or processing the response.
93100
public func send(
94101
_ request: HTTPRequest,
95102
body: HTTPBody?,
@@ -218,10 +225,12 @@ extension URLRequest {
218225
}
219226

220227
extension URLSessionTransportError: LocalizedError {
228+
/// A custom error description for `URLSessionTransportError`.
221229
public var errorDescription: String? { description }
222230
}
223231

224232
extension URLSessionTransportError: CustomStringConvertible {
233+
/// A custom textual representation for `URLSessionTransportError`.
225234
public var description: String {
226235
switch self {
227236
case let .invalidRequestURL(path: path, method: method, baseURL: baseURL):

Tests/OpenAPIURLSessionTests/Locking.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,18 @@ public final class LockedValueBox<Value: Sendable>: @unchecked Sendable {
2828
return lock
2929
}()
3030
private var value: Value
31+
/// Initializes a new `LockedValueBox` instance with the provided initial value.
32+
///
33+
/// - Parameter value: The initial value to store in the `LockedValueBox`.
3134
public init(_ value: Value) {
3235
self.value = value
3336
}
37+
/// Perform an operation on the value in a synchronized manner.
38+
///
39+
/// - Parameter work: A closure that takes an inout reference to the wrapped value and returns a result.
40+
///
41+
/// - Returns: The result of the provided closure.
42+
/// - Returns: The result of the closure passed to `work`.
3443
public func withValue<R>(_ work: (inout Value) throws -> R) rethrows -> R {
3544
lock.lock()
3645
defer {

0 commit comments

Comments
 (0)