From ee635f737a6dcc20feea18e9a13785bce3ad70e0 Mon Sep 17 00:00:00 2001 From: tom doron Date: Thu, 14 Apr 2022 15:34:23 -0700 Subject: [PATCH] remove extension for JSONEncoder and JSONDecoder motivation: we should not publicly extend types we do not own change: remove extensions which are largely API sugar that is not directly related to Lambda --- Sources/AWSLambdaRuntime/Lambda+Codable.swift | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Sources/AWSLambdaRuntime/Lambda+Codable.swift b/Sources/AWSLambdaRuntime/Lambda+Codable.swift index f7da53bd..ac9c70c6 100644 --- a/Sources/AWSLambdaRuntime/Lambda+Codable.swift +++ b/Sources/AWSLambdaRuntime/Lambda+Codable.swift @@ -76,17 +76,3 @@ extension JSONEncoder: LambdaCodableEncoder { return buffer } } - -extension JSONEncoder { - /// Convenience method to allow encoding json directly into a `String`. It can be used to encode a payload into an `APIGateway.V2.Response`'s body. - public func encodeAsString(_ value: T) throws -> String { - try String(decoding: self.encode(value), as: Unicode.UTF8.self) - } -} - -extension JSONDecoder { - /// Convenience method to allow decoding json directly from a `String`. It can be used to decode a payload from an `APIGateway.V2.Request`'s body. - public func decode(_ type: T.Type, from string: String) throws -> T { - try self.decode(type, from: Data(string.utf8)) - } -}