Skip to content

Commit 10f291c

Browse files
authored
Merge pull request #398 from mattpolzin/address-some-warnings
address some retroactive protocol conformance compiler warnings
2 parents 893529e + a4a3441 commit 10f291c

File tree

6 files changed

+44
-88
lines changed

6 files changed

+44
-88
lines changed

Sources/OpenAPIKit/Path Item/PathItem.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -236,24 +236,6 @@ extension OpenAPI.PathItem : OpenAPISummarizable {
236236

237237
// MARK: - Codable
238238

239-
extension OpenAPI.Path: Encodable {
240-
public func encode(to encoder: Encoder) throws {
241-
var container = encoder.singleValueContainer()
242-
243-
try container.encode(rawValue)
244-
}
245-
}
246-
247-
extension OpenAPI.Path: Decodable {
248-
public init(from decoder: Decoder) throws {
249-
let container = try decoder.singleValueContainer()
250-
251-
let rawValue = try container.decode(String.self)
252-
253-
self.init(rawValue: rawValue)
254-
}
255-
}
256-
257239
extension OpenAPI.PathItem: Encodable {
258240
public func encode(to encoder: Encoder) throws {
259241
var container = encoder.container(keyedBy: CodingKeys.self)

Sources/OpenAPIKit/Response/Response.swift

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -199,30 +199,4 @@ extension OpenAPI.Response: Decodable {
199199
}
200200
}
201201

202-
extension OpenAPI.Response.StatusCode: Encodable {
203-
public func encode(to encoder: Encoder) throws {
204-
var container = encoder.singleValueContainer()
205-
206-
try container.encode(self.rawValue)
207-
}
208-
}
209-
210-
extension OpenAPI.Response.StatusCode: Decodable {
211-
public init(from decoder: Decoder) throws {
212-
let container = try decoder.singleValueContainer()
213-
let strVal = try container.decode(String.self)
214-
let val = OpenAPI.Response.StatusCode(rawValue: strVal)
215-
216-
guard let value = val else {
217-
throw InconsistencyError(
218-
subjectName: "status code",
219-
details: "Expected the status code to be either an Int, a range like '1XX', or 'default' but found \(strVal) instead",
220-
codingPath: decoder.codingPath
221-
)
222-
}
223-
224-
self = value
225-
}
226-
}
227-
228202
extension OpenAPI.Response: Validatable {}

Sources/OpenAPIKit30/Path Item/PathItem.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -218,24 +218,6 @@ extension OpenAPI.PathItem {
218218

219219
// MARK: - Codable
220220

221-
extension OpenAPI.Path: Encodable {
222-
public func encode(to encoder: Encoder) throws {
223-
var container = encoder.singleValueContainer()
224-
225-
try container.encode(rawValue)
226-
}
227-
}
228-
229-
extension OpenAPI.Path: Decodable {
230-
public init(from decoder: Decoder) throws {
231-
let container = try decoder.singleValueContainer()
232-
233-
let rawValue = try container.decode(String.self)
234-
235-
self.init(rawValue: rawValue)
236-
}
237-
}
238-
239221
extension OpenAPI.PathItem: Encodable {
240222
public func encode(to encoder: Encoder) throws {
241223
var container = encoder.container(keyedBy: CodingKeys.self)

Sources/OpenAPIKit30/Response/Response.swift

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -189,30 +189,4 @@ extension OpenAPI.Response: Decodable {
189189
}
190190
}
191191

192-
extension OpenAPI.Response.StatusCode: Encodable {
193-
public func encode(to encoder: Encoder) throws {
194-
var container = encoder.singleValueContainer()
195-
196-
try container.encode(self.rawValue)
197-
}
198-
}
199-
200-
extension OpenAPI.Response.StatusCode: Decodable {
201-
public init(from decoder: Decoder) throws {
202-
let container = try decoder.singleValueContainer()
203-
let strVal = try container.decode(String.self)
204-
let val = OpenAPI.Response.StatusCode(rawValue: strVal)
205-
206-
guard let value = val else {
207-
throw InconsistencyError(
208-
subjectName: "status code",
209-
details: "Expected the status code to be either an Int, a range like '1XX', or 'default' but found \(strVal) instead",
210-
codingPath: decoder.codingPath
211-
)
212-
}
213-
214-
self = value
215-
}
216-
}
217-
218192
extension OpenAPI.Response: Validatable {}

Sources/OpenAPIKitCore/Shared/Path.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,21 @@ extension Shared.Path: ExpressibleByStringLiteral {
4343
self.init(rawValue: value)
4444
}
4545
}
46+
47+
extension Shared.Path: Encodable {
48+
public func encode(to encoder: Encoder) throws {
49+
var container = encoder.singleValueContainer()
50+
51+
try container.encode(rawValue)
52+
}
53+
}
54+
55+
extension Shared.Path: Decodable {
56+
public init(from decoder: Decoder) throws {
57+
let container = try decoder.singleValueContainer()
58+
59+
let rawValue = try container.decode(String.self)
60+
61+
self.init(rawValue: rawValue)
62+
}
63+
}

Sources/OpenAPIKitCore/Shared/ResponseStatusCode.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,29 @@ extension Shared.ResponseStatusCode: ExpressibleByIntegerLiteral {
106106
warnings = []
107107
}
108108
}
109+
110+
extension Shared.ResponseStatusCode: Encodable {
111+
public func encode(to encoder: Encoder) throws {
112+
var container = encoder.singleValueContainer()
113+
114+
try container.encode(self.rawValue)
115+
}
116+
}
117+
118+
extension Shared.ResponseStatusCode: Decodable {
119+
public init(from decoder: Decoder) throws {
120+
let container = try decoder.singleValueContainer()
121+
let strVal = try container.decode(String.self)
122+
let val = Shared.ResponseStatusCode(rawValue: strVal)
123+
124+
guard let value = val else {
125+
throw InconsistencyError(
126+
subjectName: "status code",
127+
details: "Expected the status code to be either an Int, a range like '1XX', or 'default' but found \(strVal) instead",
128+
codingPath: decoder.codingPath
129+
)
130+
}
131+
132+
self = value
133+
}
134+
}

0 commit comments

Comments
 (0)