Skip to content

Commit 19eda4b

Browse files
committed
A bit more documentation and some more whitespace changes
1 parent f998822 commit 19eda4b

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

Sources/OpenAPIKit/Either/Either.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ public enum Either<A, B> {
1818
case a(A)
1919
case b(B)
2020

21+
/// Get the first of the possible values of the `Either` (if it is
22+
/// set).
23+
///
24+
/// This is sometimes known as the `Left` or error case of some
25+
/// `Either` types, but `OpenAPIKit` makes regular use of
26+
/// this type in situations where neither of the possible values could
27+
/// be considered an error. In fact, `OpenAPIKit` sticks to using
28+
/// the Swift `Result` type where such semantics are needed.
2129
public var a: A? {
2230
guard case let .a(ret) = self else { return nil }
2331
return ret
@@ -27,6 +35,8 @@ public enum Either<A, B> {
2735
self = .a(a)
2836
}
2937

38+
/// Get the second of the possible values of the `Either` (if
39+
/// it is set).
3040
public var b: B? {
3141
guard case let .b(ret) = self else { return nil }
3242
return ret

Sources/OpenAPIKit/Header/Header.swift

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@ extension OpenAPI.Header {
103103

104104
// MARK: - Header Convenience
105105
extension OpenAPI.Parameter.SchemaContext {
106-
public static func header(_ schema: JSONSchema,
107-
allowReserved: Bool = false,
108-
example: AnyCodable? = nil) -> Self {
106+
public static func header(
107+
_ schema: JSONSchema,
108+
allowReserved: Bool = false,
109+
example: AnyCodable? = nil
110+
) -> Self {
109111
return .init(
110112
schema,
111113
style: .default(for: .header),
@@ -114,9 +116,11 @@ extension OpenAPI.Parameter.SchemaContext {
114116
)
115117
}
116118

117-
public static func header(schemaReference: JSONReference<JSONSchema>,
118-
allowReserved: Bool = false,
119-
example: AnyCodable? = nil) -> Self {
119+
public static func header(
120+
schemaReference: JSONReference<JSONSchema>,
121+
allowReserved: Bool = false,
122+
example: AnyCodable? = nil
123+
) -> Self {
120124
return .init(
121125
schemaReference: schemaReference,
122126
style: .default(for: .header),
@@ -125,9 +129,11 @@ extension OpenAPI.Parameter.SchemaContext {
125129
)
126130
}
127131

128-
public static func header(_ schema: JSONSchema,
129-
allowReserved: Bool = false,
130-
examples: OpenAPI.Example.Map?) -> Self {
132+
public static func header(
133+
_ schema: JSONSchema,
134+
allowReserved: Bool = false,
135+
examples: OpenAPI.Example.Map?
136+
) -> Self {
131137
return .init(
132138
schema,
133139
style: .default(for: .header),
@@ -136,9 +142,11 @@ extension OpenAPI.Parameter.SchemaContext {
136142
)
137143
}
138144

139-
public static func header(schemaReference: JSONReference<JSONSchema>,
140-
allowReserved: Bool = false,
141-
examples: OpenAPI.Example.Map?) -> Self {
145+
public static func header(
146+
schemaReference: JSONReference<JSONSchema>,
147+
allowReserved: Bool = false,
148+
examples: OpenAPI.Example.Map?
149+
) -> Self {
142150
return .init(
143151
schemaReference: schemaReference,
144152
style: .default(for: .header),

Sources/OpenAPIKit/OrderedDictionary/OrderedDictionary.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ public struct OrderedDictionary<Key, Value> where Key: Hashable {
2626
unorderedHash = [:]
2727
}
2828

29-
public init<S>(grouping values: S, by keyForValue: (S.Element) throws -> Key) rethrows where Value == [S.Element], S : Sequence {
29+
public init<S>(
30+
grouping values: S,
31+
by keyForValue: (S.Element) throws -> Key
32+
) rethrows where Value == [S.Element], S : Sequence {
3033
var temporaryDictionary = Self()
3134

3235
for value in values {
@@ -35,7 +38,10 @@ public struct OrderedDictionary<Key, Value> where Key: Hashable {
3538
self = temporaryDictionary
3639
}
3740

38-
public init<S>(_ keysAndValues: S, uniquingKeysWith combine: (Value, Value) throws -> Value) rethrows where S : Sequence, S.Element == (Key, Value) {
41+
public init<S>(
42+
_ keysAndValues: S,
43+
uniquingKeysWith combine: (Value, Value) throws -> Value
44+
) rethrows where S : Sequence, S.Element == (Key, Value) {
3945
var temporaryDictionary = Self()
4046

4147
for (key, value) in keysAndValues {

0 commit comments

Comments
 (0)