Skip to content

Commit a712190

Browse files
committed
Reformat
1 parent 52746e5 commit a712190

File tree

4 files changed

+18
-39
lines changed

4 files changed

+18
-39
lines changed

Sources/OpenAPIRuntime/URICoder/Serialization/URISerializer.swift

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,11 @@ extension URISerializer {
8282
/// - Returns: A string describing the serialization error and its associated details.
8383
var description: String {
8484
switch self {
85-
case .nestedContainersNotSupported:
86-
"URISerializer: Nested containers are not supported"
87-
case .deepObjectsArrayNotSupported:
88-
"URISerializer: Deep object arrays are not supported"
85+
case .nestedContainersNotSupported: "URISerializer: Nested containers are not supported"
86+
case .deepObjectsArrayNotSupported: "URISerializer: Deep object arrays are not supported"
8987
case .deepObjectsWithPrimitiveValuesNotSupported:
9088
"URISerializer: Deep object with primitive values are not supported"
91-
case .invalidConfiguration(let string):
92-
"URISerializer: Invalid configuration: \(string)"
89+
case .invalidConfiguration(let string): "URISerializer: Invalid configuration: \(string)"
9390
}
9491
}
9592

@@ -98,9 +95,7 @@ extension URISerializer {
9895
/// This computed property provides a localized human-readable description of the serialization error, which is suitable for displaying to users.
9996
///
10097
/// - Returns: A localized string describing the serialization error.
101-
var errorDescription: String? {
102-
description
103-
}
98+
var errorDescription: String? { description }
10499
}
105100

106101
/// Computes an escaped version of the provided string.
@@ -140,12 +135,10 @@ extension URISerializer {
140135
guard case let .primitive(primitive) = node else { throw SerializationError.nestedContainersNotSupported }
141136
return primitive
142137
}
143-
func unwrapPrimitiveOrArrayOfPrimitives(
144-
_ node: URIEncodedNode
145-
) throws -> URIEncodedNode.PrimitiveOrArrayOfPrimitives {
146-
if case let .primitive(primitive) = node {
147-
return .primitive(primitive)
148-
}
138+
func unwrapPrimitiveOrArrayOfPrimitives(_ node: URIEncodedNode) throws
139+
-> URIEncodedNode.PrimitiveOrArrayOfPrimitives
140+
{
141+
if case let .primitive(primitive) = node { return .primitive(primitive) }
149142
if case let .array(array) = node {
150143
let primitives = try array.map(unwrapPrimitiveValue)
151144
return .arrayOfPrimitives(primitives)
@@ -292,22 +285,12 @@ extension URISerializer {
292285
case .primitive(let primitive):
293286
try serializePrimitiveKeyValuePair(primitive, forKey: elementKey, separator: keyAndValueSeparator)
294287
case .arrayOfPrimitives(let array):
295-
guard !array.isEmpty else {
296-
return
297-
}
288+
guard !array.isEmpty else { return }
298289
for item in array.dropLast() {
299-
try serializePrimitiveKeyValuePair(
300-
item,
301-
forKey: elementKey,
302-
separator: keyAndValueSeparator
303-
)
290+
try serializePrimitiveKeyValuePair(item, forKey: elementKey, separator: keyAndValueSeparator)
304291
data.append(pairSeparator)
305292
}
306-
try serializePrimitiveKeyValuePair(
307-
array.last!,
308-
forKey: elementKey,
309-
separator: keyAndValueSeparator
310-
)
293+
try serializePrimitiveKeyValuePair(array.last!, forKey: elementKey, separator: keyAndValueSeparator)
311294
}
312295
}
313296
if let containerKeyAndValue = configuration.containerKeyAndValueSeparator {

Tests/OpenAPIRuntimeTests/URICoder/Decoder/Test_URIValueFromNodeDecoder.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ final class Test_URIValueFromNodeDecoder: Test_Runtime {
6767

6868
// A struct with an array property.
6969
try test(
70-
[
71-
"foo": ["bar"],
72-
"bar": ["1", "2"],
73-
"val": ["baz", "baq"]
74-
],
70+
["foo": ["bar"], "bar": ["1", "2"], "val": ["baz", "baq"]],
7571
StructWithArray(foo: "bar", bar: [1, 2], val: ["baz", "baq"]),
7672
key: "root"
7773
)

Tests/OpenAPIRuntimeTests/URICoder/Parsing/Test_URIParser.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ final class Test_URIParser: Test_Runtime {
7979
simpleUnexplode: .custom("red,green,blue", value: ["": ["red", "green", "blue"]]),
8080
formDataExplode: "list=red&list=green&list=blue",
8181
formDataUnexplode: "list=red,green,blue",
82-
deepObjectExplode:
83-
"object%5Blist%5D=red&object%5Blist%5D=green&object%5Blist%5D=blue"
82+
deepObjectExplode: "object%5Blist%5D=red&object%5Blist%5D=green&object%5Blist%5D=blue"
8483
),
8584
value: ["list": ["red", "green", "blue"]]
8685
),
@@ -101,7 +100,8 @@ final class Test_URIParser: Test_Runtime {
101100
"keys=comma,%2C,dot,.,list,one,list,two,semi,%3B",
102101
value: ["keys": ["comma", ",", "dot", ".", "list", "one", "list", "two", "semi", ";"]]
103102
),
104-
deepObjectExplode: "keys%5Bcomma%5D=%2C&keys%5Bdot%5D=.&keys%5Blist%5D=one&keys%5Blist%5D=two&keys%5Bsemi%5D=%3B"
103+
deepObjectExplode:
104+
"keys%5Bcomma%5D=%2C&keys%5Bdot%5D=.&keys%5Blist%5D=one&keys%5Blist%5D=two&keys%5Bsemi%5D=%3B"
105105
),
106106
value: ["semi": [";"], "dot": ["."], "comma": [","], "list": ["one", "two"]]
107107
),

Tests/OpenAPIRuntimeTests/URICoder/Serialization/Test_URISerializer.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ final class Test_URISerializer: Test_Runtime {
124124
),
125125
makeCase(
126126
value: .dictionary([
127-
"semi": .primitive(.string(";")),
128-
"dot": .primitive(.string(".")),
127+
"semi": .primitive(.string(";")), "dot": .primitive(.string(".")),
129128
"comma": .primitive(.string(",")),
130129
"list": .array([.primitive(.string("one")), .primitive(.string("two"))]),
131130
]),
@@ -137,7 +136,8 @@ final class Test_URISerializer: Test_Runtime {
137136
simpleUnexplode: "comma,%2C,dot,.,list,one,list,two,semi,%3B",
138137
formDataExplode: "comma=%2C&dot=.&list=one&list=two&semi=%3B",
139138
formDataUnexplode: "keys=comma,%2C,dot,.,list,one,list,two,semi,%3B",
140-
deepObjectExplode: "keys%5Bcomma%5D=%2C&keys%5Bdot%5D=.&keys%5Blist%5D=one&keys%5Blist%5D=two&keys%5Bsemi%5D=%3B"
139+
deepObjectExplode:
140+
"keys%5Bcomma%5D=%2C&keys%5Bdot%5D=.&keys%5Blist%5D=one&keys%5Blist%5D=two&keys%5Bsemi%5D=%3B"
141141
)
142142
),
143143
]

0 commit comments

Comments
 (0)