repo_name stringlengths 1 62 | dataset stringclasses 1
value | lang stringclasses 11
values | pr_id int64 1 20.1k | owner stringlengths 2 34 | reviewer stringlengths 2 39 | diff_hunk stringlengths 15 262k | code_review_comment stringlengths 1 99.6k |
|---|---|---|---|---|---|---|---|
swift-openapi-runtime | github_2023 | others | 55 | apple | czechboy0 | @@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
/// However more commonly the decoding initializer would be called by a decoder, for example:
``` |
swift-openapi-runtime | github_2023 | others | 55 | apple | czechboy0 | @@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
/// However more commonly it would be called by an encoder, for example:
``` |
swift-openapi-runtime | github_2023 | others | 55 | apple | czechboy0 | @@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
/// A container of the raw bytes.
``` |
swift-openapi-runtime | github_2023 | others | 55 | apple | czechboy0 | @@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
public init(from decoder: any Decoder) throws {
```
We skip documenting conformances. |
swift-openapi-runtime | github_2023 | others | 55 | apple | czechboy0 | @@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
public func encode(to encoder: any Encoder) throws {
```
Same here. |
swift-openapi-runtime | github_2023 | others | 55 | apple | czechboy0 | @@ -73,6 +74,8 @@ internal enum RuntimeError: Error, CustomStringConvertible, LocalizedError, Pret
return "Invalid expected content type: '\(string)'"
case .invalidHeaderFieldName(let name):
return "Invalid header field name: '\(name)'"
+ case .invalidBase64String(let string):
... | Let's cap how many bytes we'd actually print.
```suggestion
return "Invalid base64-encoded string (first 128 bytes): '\(string.prefix(128))'"
``` |
swift-openapi-runtime | github_2023 | others | 56 | apple | czechboy0 | @@ -96,6 +100,20 @@ internal enum RuntimeError: Error, CustomStringConvertible, LocalizedError, Pret
return "Transport failed with error: \(underlyingError.localizedDescription)"
case .handlerFailed(let underlyingError):
return "User handler failed with error: \(underlyingError.locali... | ```suggestion
case .unexpectedResponseBody(let expectedContentType, let body):
return "Unexpected response body, expected content type: \(expectedContentType), body: \(body)"
``` |
swift-openapi-runtime | github_2023 | others | 56 | apple | czechboy0 | @@ -96,6 +100,20 @@ internal enum RuntimeError: Error, CustomStringConvertible, LocalizedError, Pret
return "Transport failed with error: \(underlyingError.localizedDescription)"
case .handlerFailed(let underlyingError):
return "User handler failed with error: \(underlyingError.locali... | I think these could go into `ErrorExtensions.swift`, and maybe return the constructed error rather than throw it (similar to `DecodingError.failedToDecodeAnySchema(...)` etc). |
swift-openapi-runtime | github_2023 | others | 47 | apple | FranzBusch | @@ -47,7 +47,7 @@
"UseLetInEveryBoundCaseVariable" : false,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : false,
- "UseSynthesizedInitializer" : true,
+ "UseSynthesizedInitializer" : false, | Can we report this upstream? |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Do you think there's any benefit to putting the locking in some accessors so we don't forget to do it at the call site?
```suggestion
private var _iteratorCreated: Bool = false
private var iteratorCreated: Bool {
get {
lock.lock()
defer { lock.unlock() }
retu... |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
/// - length: The total length of the body.
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
/// - length: The total length of the body.
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
/// - length: The total length of the body.
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
var buffer = ByteChunk()
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | In the case where `self.length == .known` we should fail early and leave the sequence un-iterated. |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
ByteChunk(string),
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
ByteChunk(string),
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
self.init(stream.map(ByteChunk.init)),
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
self.init(stream.map(ByteChunk.init)),
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
self.init(sequence.map(ByteChunk.init)),
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | This function doesn't take a "provided encoding" and unilaterally uses UTF8. We should either update the docs or the function. |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
/// Creates a Data by accumulating the full body in-memory into a single buffer up to
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,754 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
self.init(sequence.makeAsyncIterator())
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -142,53 +110,42 @@ extension Converter {
// | client | set | request body | binary | optional | setOptionalRequestBodyAsBinary |
public func setOptionalRequestBodyAsBinary(
- _ value: Data?,
- headerFields: inout [HeaderField],
+ _ value: HTTPBody?,
+ headerFields: inout HT... | These functions used to take non-optional `Data`. Why are they now taking optional `HTTPBody?`? |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -114,10 +43,44 @@ extension ParameterStyle {
}
}
+extension HTTPField.Name {
+
+ /// Creates a new name for the provided string.
+ /// - Parameter name: A field name.
+ /// - Throws: If the name isn't a valid field name.
+ init(validated name: String) throws {
+ guard let fieldName = Self.... | ```suggestion
guard let fieldName = Self(name) else {
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -312,17 +306,50 @@ extension Converter {
style: style,
explode: explode
)
- let uriSnippet = try convert(value, resolvedStyle, resolvedExplode)
- request.addEscapedQuerySnippet(uriSnippet)
+ let escapedUriSnippet = try convert(value, resolvedStyle, resolvedExpl... | Do we have new tests to cover this revised logic? I didn't see any, and it looks like Test_CurrencyExtensions has been deleted. |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -35,7 +40,13 @@ public struct ClientError: Error {
///
/// Will be nil if the error resulted before the request was generated,
/// for example if generating the request from the Input failed.
- public var request: Request?
+ public var request: HTTPRequest?
+
+ /// The HTTP request body creat... | Have we considered keeping these as a tuple in our layer given they are only ever both nil under the same circumstance. If that claim is false, then the docs for `requestBody` should be updated to include the case where we expect to have a nil body.
Ditto: for `response` and `responseBody`. |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -11,25 +11,31 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
-import Foundation
+
+import HTTPTypes
+import protocol Foundation.LocalizedError
/// An error thrown by a server handling an OpenAPI operation.
public struct ServerError... | Why did this change? FWIW I think it was clearer before as it made the distinction between request metadata and metadata about the error. |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -122,14 +132,16 @@ public protocol ClientTransport: Sendable {
/// HTTP response.
/// - Parameters:
/// - request: An HTTP request.
+ /// - body: An HTTP request body.
/// - baseURL: A server base URL.
/// - operationID: The identifier of the OpenAPI operation.
- /// - Returns:... | Can this return a tuple with named parameters, then we can access with e.g. `.body`, rather than `.1`?
Similar for middleware. |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -11,281 +11,100 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
-#if canImport(Darwin)
-import Foundation
-#else
-@preconcurrency import struct Foundation.Data
-@preconcurrency import struct Foundation.URLQueryItem
-#endif
-/// A head... | Are we having the `soar_path` label in the API? If this is a value-preserving type conversion we probably want `init(from:method:headerFields:)` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -11,281 +11,100 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
-#if canImport(Darwin)
-import Foundation
-#else
-@preconcurrency import struct Foundation.Data
-@preconcurrency import struct Foundation.URLQueryItem
-#endif
-/// A head... | Do we want these in the public API? Are they used by the end-user or the transport? If it's the latter, should we consider making a new SPI "transport", like we have "generated"? |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -11,281 +11,100 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
-#if canImport(Darwin)
-import Foundation
-#else
-@preconcurrency import struct Foundation.Data
-@preconcurrency import struct Foundation.URLQueryItem
-#endif
-/// A head... | I don't understand. The docs imply this is a string, but it is an integer parameter. If it's an integer, surely there's no divergence between what it means and we can just name this `statusCode` in the API? |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -108,14 +110,15 @@ public protocol ServerTransport {
/// - Parameters:
/// - handler: A handler to be invoked when an HTTP request is received.
/// - method: An HTTP request method.
- /// - path: The URL path components, for example `["pets", ":petId"]`.
- /// - queryItemNames: The names... | ```suggestion
/// - Important: The `path` can have mixed components, such
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -13,6 +13,13 @@
//===----------------------------------------------------------------------===//
import XCTest
@_spi(Generated)@testable import OpenAPIRuntime
+import HTTPTypes
+
+extension HTTPField.Name {
+ static var foo: Self {
+ .init("foo")! | ```suggestion
Self("foo")!
``` |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,189 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | This test is identical to `// A single string.`. |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,189 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Can we add some with "unknown" length (even if we do really know the length)? |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -0,0 +1,189 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | There are no error tests for iterating a sequence more than once? |
swift-openapi-runtime | github_2023 | others | 47 | apple | simonjbeaumont | @@ -427,18 +438,14 @@ extension HTTPBody {
// iterate a sequence for the second time, if it's only safe to be
// iterated once.
if iterationBehavior == .single {
- try {
- lock.lock()
- defer {
- lock.unlock()
- }
- ... | Shouldn't we be setting `iteratorCreated` to true here?
Maybe we'd be better to rework the new `withIteratorCreated<R>(_:)` to be the place where this is set, so the semantics of it become:
- If it's already been set throw;
- If it's not set, set it, and perform the provided operation. |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -273,6 +273,34 @@ extension Converter {
)
}
+ // | server | get | request body | URLEncodedForm | codable | optional | getOptionalRequestBodyAsURLEncodedForm | | Please add the `getOptionalRequestBodyAsURLEncodedForm` names to the documentation at `Sources/swift-openapi-generator/Documentation.docc/Development/Converting-between-data-and-Swift-types.md` as well, in the same location in the list as here in the implementation. |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -177,12 +177,50 @@ extension Converter {
try decoder.decode(T.self, from: data)
}
+ func convertURLEncodedFormToCodable<T: Decodable>(
+ _ data: Data
+ ) throws -> T {
+
+ let decoder = URIDecoder(
+ configuration: .init(
+ style: .form,
+ ... | ```suggestion
spaceEscapingCharacter: .plus,
```
According to https://www.rfc-editor.org/rfc/rfc1866.html#section-8.2.1
> 1. The form field names and values are escaped: space
characters are replaced by `+', and then reserved characters
are escaped as per [URL]; |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -23,6 +23,7 @@ internal enum RuntimeError: Error, CustomStringConvertible, LocalizedError, Pret
// Data conversion
case failedToDecodeStringConvertibleValue(type: String)
+ case failedToSerializeCodableData | You can get rid of this, we'll never hit it with my suggestion above. |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -177,12 +177,50 @@ extension Converter {
try decoder.decode(T.self, from: data)
}
+ func convertURLEncodedFormToCodable<T: Decodable>(
+ _ data: Data
+ ) throws -> T {
+
+ let decoder = URIDecoder(
+ configuration: .init(
+ style: .form,
+ ... | Prefer `String(decoding: data, as: UTF8.self)` which isn't failable. |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -177,12 +177,50 @@ extension Converter {
try decoder.decode(T.self, from: data)
}
+ func convertURLEncodedFormToCodable<T: Decodable>(
+ _ data: Data
+ ) throws -> T {
+
+ let decoder = URIDecoder(
+ configuration: .init(
+ style: .form,
+ ... | ```suggestion
spaceEscapingCharacter: .plus,
```
See above. |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -177,12 +177,50 @@ extension Converter {
try decoder.decode(T.self, from: data)
}
+ func convertURLEncodedFormToCodable<T: Decodable>(
+ _ data: Data
+ ) throws -> T {
+
+ let decoder = URIDecoder(
+ configuration: .init(
+ style: .form,
+ ... | To convert the string to Data, use `Data(string.utf8)` instead, as that's not failable and we don't need to handle the error. |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -98,6 +102,10 @@ class Test_Runtime: XCTestCase {
"""#
}
+ var testStructURLFormString: String {
+ "age=3&name=Fluffz&type=Dog" | Please make one of the strings have a space, and a special character, to verify escaping. |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -234,6 +234,59 @@ final class Test_ClientConverterExtensions: Test_Runtime {
)
}
+ // | client | set | request body | urlEncodedForm | codable | optional | setRequiredRequestBodyAsURLEncodedForm |
+ func test_setOptionalRequestBodyAsURLEncodedForm_codable() throws {
+ var headerFields... | I don't think you need this test, it's testing the same logic as above just comparing using data vs string, am I reading it correctly? |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -234,6 +234,59 @@ final class Test_ClientConverterExtensions: Test_Runtime {
)
}
+ // | client | set | request body | urlEncodedForm | codable | optional | setRequiredRequestBodyAsURLEncodedForm |
+ func test_setOptionalRequestBodyAsURLEncodedForm_codable() throws {
+ var headerFields... | It's fine to just compare it using `XCTAssertEqual(body, testStructURLFormData)`.
Alternatively, you could bring over `XCTAssertEqualStringifiedData` from the generator repo. |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -177,12 +177,45 @@ extension Converter {
try decoder.decode(T.self, from: data)
}
+ func convertURLEncodedFormToCodable<T: Decodable>(
+ _ data: Data
+ ) throws -> T {
+ | ```suggestion
``` |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -177,12 +177,45 @@ extension Converter {
try decoder.decode(T.self, from: data)
}
+ func convertURLEncodedFormToCodable<T: Decodable>(
+ _ data: Data
+ ) throws -> T {
+
+ let decoder = URIDecoder(
+ configuration: .init(
+ style: .form,
+ ... | ```suggestion
``` |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
import XCTest
@_spi(Generated)@testable import OpenAPIRuntime
+import PetstoreConsumerTestCore | ```suggestion
``` |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -339,6 +339,26 @@ final class Test_ServerConverterExtensions: Test_Runtime {
XCTAssertEqual(body, testStruct)
}
+ // | server | get | request body | URLEncodedForm | optional | getOptionalRequestBodyAsJSON | | ```suggestion
// | server | get | request body | urlEncodedForm | optional | getOptionalRequestBodyAsURLEncodedForm |
``` |
swift-openapi-runtime | github_2023 | others | 53 | apple | czechboy0 | @@ -339,6 +339,26 @@ final class Test_ServerConverterExtensions: Test_Runtime {
XCTAssertEqual(body, testStruct)
}
+ // | server | get | request body | URLEncodedForm | optional | getOptionalRequestBodyAsJSON |
+ func test_getOptionalRequestBodyAsURLEncodedForm_codable() throws {
+ let b... | ```suggestion
// | server | get | request body | urlEncodedForm | required | getRequiredRequestBodyAsURLEncodedForm |
``` |
swift-openapi-runtime | github_2023 | others | 52 | apple | czechboy0 | @@ -294,6 +294,10 @@ extension URIValueFromNodeDecoder {
array = try rootValue(in: values)
}
guard array.count == 1 else {
+ if style == .simple {
+ return Substring(array.joined(separator: ","))
+ }
+ | ```suggestion
``` |
swift-openapi-runtime | github_2023 | others | 39 | apple | czechboy0 | @@ -158,12 +158,56 @@ extension Converter {
) throws -> T {
try decoder.decode(T.self, from: data)
}
+
+ func convertURLEncodedFormToCodable<T:Decodable>(
+ _ data: Data
+ ) throws -> T {
+ // convert data to string
+ guard let urlFormString = String(data: data, encodin... | What happens if the Codable type has a property `foo: Int`? I suspect it won't parse, as in the JSON it'll be `"1"` instead of `1`? Same for other non-string primitive types that have a native JSON type? |
swift-openapi-runtime | github_2023 | others | 50 | apple | glbrntt | @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//
import XCTest
-@testable import OpenAPIRuntime
+@_spi(Generated)@testable import OpenAPIRuntime
+#if os(Linux)
+@preconcurrency import Foundation | Why don't we need a `Foundation` import on other platforms? Should we use a more specific `Foundation` import here (i.e. for the types we're using)? |
swift-openapi-runtime | github_2023 | others | 50 | apple | glbrntt | @@ -17,26 +17,27 @@ import Foundation
/// A single value container used by `URIValueFromNodeDecoder`.
struct URISingleValueDecodingContainer {
- /// The coder used to serialize Date values.
- let dateTranscoder: any DateTranscoder
-
- /// The coding path of the container.
- let codingPath: [any CodingKe... | Why are these all throwing now? |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Why is this a class? Also can we get rid of the `@unchecked Sendable` here and rather make ourselves a `LockedValueBox` abstraction that is conditionally `Sendable` when its contents are. This way we are making sure we really are `Sendable` |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | This probably should be a `struct`. |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Are we ever expecting an `AsyncSequence` based body to be `multiple` here? Right now that just doesn't exist in the ecosystem. |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Same here. Probably a `struct` |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | I am not sure if we really need `Equatable` and `Hashable` on the body |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | These two methods seem unnecessary when you already have the generic one which takes an `AsyncSequence` |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | We shouldn't have to do this at all. If we just delegate to call `makeAsyncIterator` on the underlying sequence then that base async sequence should enforce if it is `unicast` or `multicast`. |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Interesting. What is the use-case for this? |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | This contradicts each other. Collects the whole body and up to. |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Same here. Shouldn't have to do that. |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | FWIW in async-altos we spelled this like that [AsyncSyncSequence](https://github.com/apple/swift-async-algorithms/blob/4a1fb99f0089a9d9db07859bcad55b4a77e3c3dd/Sources/AsyncAlgorithms/AsyncSyncSequence.swift#L17). Maybe we should just add a variant with a `upTo` in async-algos. |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Same here as above. |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | IMO this doesn't carry its weight for me since it is a one-liner for the user. |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Why are we not storing the iterator here but a closure? |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Same here |
swift-openapi-runtime | github_2023 | others | 46 | apple | FranzBusch | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | FWIW we have this in async-algorithms. |
swift-openapi-runtime | github_2023 | others | 46 | apple | dnadoba | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | What's the use case for this method? |
swift-openapi-runtime | github_2023 | others | 46 | apple | dnadoba | @@ -0,0 +1,535 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | `@inlinable` or otherwise quite slow as this is a generic over `StringProtocol` |
swift-openapi-runtime | github_2023 | others | 24 | apple | simonjbeaumont | @@ -143,6 +143,18 @@ public struct OpenAPIValueContainer: Codable, Equatable, Hashable, Sendable {
try container.encode(value.map(OpenAPIValueContainer.init(validatedValue:)))
case let value as [String: OpenAPIValueContainer?]:
try container.encode(value.mapValues(OpenAPIValueContaine... | Couple of suggestions here:
- We'll be landing #22 soon which means that you'll need to use existential any, i.e. `any Sendable` in place of `Sendable`, so we may as well get it right here so it doesn't need updating again.
- The rest of the switch statement follows a different style of passing `init(unvalidatedVal... |
swift-openapi-runtime | github_2023 | others | 24 | apple | czechboy0 | @@ -193,4 +193,96 @@ final class Test_OpenAPIValue: Test_Runtime {
XCTAssertEqual(value[0] as? String, "one")
XCTAssertEqual(value[1] as? [String: Int], ["two": 2])
}
+
+ func testEncoding_objectNested_success() throws {
+
+ struct Foo: Encodable {
+ var bar: String
+ ... | Please make it consistent with the other tests by using the utility functions that does the encoding/decoding and equality checks. |
swift-openapi-runtime | github_2023 | others | 24 | apple | czechboy0 | @@ -193,4 +193,96 @@ final class Test_OpenAPIValue: Test_Runtime {
XCTAssertEqual(value[0] as? String, "one")
XCTAssertEqual(value[1] as? [String: Int], ["two": 2])
}
+
+ func testEncoding_objectNested_success() throws {
+
+ struct Foo: Encodable {
+ var bar: String
+ ... | Why is this extra do scope here? |
swift-openapi-runtime | github_2023 | others | 24 | apple | czechboy0 | @@ -193,4 +193,96 @@ final class Test_OpenAPIValue: Test_Runtime {
XCTAssertEqual(value[0] as? String, "one")
XCTAssertEqual(value[1] as? [String: Int], ["two": 2])
}
+
+ func testEncoding_objectNested_success() throws {
+
+ struct Foo: Encodable {
+ var bar: String
+ ... | Same here about the do scope. |
swift-openapi-runtime | github_2023 | others | 45 | apple | glbrntt | @@ -31,98 +31,61 @@ extension Converter {
)
}
- // | client | set | request path | text | string-convertible | required | renderedRequestPath |
- public func renderedRequestPath(
+ // | client | set | request path | URI | required | renderedPath | | what's this notation? |
swift-openapi-runtime | github_2023 | others | 41 | apple | bfrearson | @@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LICE... | Minor point, but spaceEscapingCharacter might be better as an enum so we can be sure that we're always using the same value:
```
enum SpaceEscapingCharacter: String {
case percent = "%20"
case plus = "+"
}
``` |
swift-openapi-runtime | github_2023 | others | 41 | apple | bfrearson | @@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LICE... | I'd be interested how much of a performance improvement this offers! Obviously optimisation is a good thing, but just curious if it makes a meaningful impact. |
swift-openapi-runtime | github_2023 | others | 41 | apple | glbrntt | @@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Should we be preconditioning that `key.intValue == 0`? |
swift-openapi-runtime | github_2023 | others | 41 | apple | glbrntt | @@ -0,0 +1,365 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | returning `Never`, that's neat. |
swift-openapi-runtime | github_2023 | others | 44 | apple | glbrntt | @@ -0,0 +1,449 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | This comment is duplicated |
swift-openapi-runtime | github_2023 | others | 37 | apple | glbrntt | @@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Is this intentionally backwards? |
swift-openapi-runtime | github_2023 | others | 37 | apple | glbrntt | @@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Any reason these shouldn't be `var`s? |
swift-openapi-runtime | github_2023 | others | 37 | apple | glbrntt | @@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | The `contentType` should come first as a required parameter. |
swift-openapi-runtime | github_2023 | others | 37 | apple | glbrntt | @@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
guard let typeAndSubtype = T(rawValue: validMimeType.kind.description.lowercased()) else {
``` |
swift-openapi-runtime | github_2023 | others | 37 | apple | glbrntt | @@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Presumably this should be `a.doubleValue > b.doubleValue`? |
swift-openapi-runtime | github_2023 | others | 37 | apple | glbrntt | @@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | What do we get from this being `RawRepresentable`? It feels a bit odd having the `RawValue` be a `String`; on first though `Double` seems like a more natural fit. |
swift-openapi-runtime | github_2023 | others | 37 | apple | glbrntt | @@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Can we use `ContentType` instead of `T`? |
swift-openapi-runtime | github_2023 | others | 37 | apple | glbrntt | @@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | I think the spelling would be something like:
```swift
extension Array {
func sortedByQuality<T: AcceptableProtocol>() -> [AcceptHeaderContentType<T>] where Element == AcceptHeaderContentType<T> {
// ...
}
}
``` |
swift-openapi-runtime | github_2023 | others | 37 | apple | gjcairo | @@ -0,0 +1,164 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | A nit, but are we explicitly listing `Hashable` _**and**_ `Equatable` on purpose? Otherwise, `Hashable` already conforms to `Equatable` so we can omit the latter. |
swift-openapi-runtime | github_2023 | others | 37 | apple | gjcairo | @@ -0,0 +1,164 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Feels like we should also precondition here that we're within a valid range - and multiplying by 1000 is probably unwanted too. |
swift-openapi-runtime | github_2023 | others | 37 | apple | gjcairo | @@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | I think it would be worth adding an assertion/a test for creating a `QualityValue` from a number with 3 decimal non-zero digits, to make sure that we're preserving them properly (which is basically the whole reason why we store it as `thousands` internally) |
swift-openapi-runtime | github_2023 | others | 37 | apple | glbrntt | @@ -0,0 +1,167 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Is this actually necessary? I assume the compiler would infer `0`/`1` to be a `Float` if this didn't exist and use the `ExpressibleByFloatLiteral` conformance. |
swift-openapi-runtime | github_2023 | others | 37 | apple | glbrntt | @@ -0,0 +1,167 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Without reading the docs it's not obvious that `let q = QualityValue()` would default to 1.0. From a readability perspective it might make more sense to not have a default init. |
swift-openapi-runtime | github_2023 | others | 37 | apple | glbrntt | @@ -0,0 +1,167 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | ```suggestion
/// - Precondition: Quality must be in the range 0.0 and 1.0 inclusive.
``` |
swift-openapi-runtime | github_2023 | others | 36 | apple | czechboy0 | @@ -14,7 +14,7 @@
#if canImport(Darwin)
import Foundation
#else
-@preconcurrency import Foundation
+@preconcurrency import Foundation.NSLock | ```suggestion
@preconcurrency import class Foundation.NSLock
```
Credit goes to CI for discovering this. |
swift-openapi-runtime | github_2023 | others | 35 | apple | glbrntt | @@ -259,36 +286,65 @@ extension Converter {
func setQueryItem<T>(
in request: inout Request,
+ style: ParameterStyle?,
+ explode: Bool?,
name: String,
value: T?,
convert: (T) throws -> String
) throws {
guard let value else {
return
... | Are we using this just for the side effect of validation? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.