Skip to content

Commit

Permalink
Fix Package.swift & Fix Alamofire issue tristanhimmelman#299
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Charles Neboit committed Jan 22, 2020
1 parent 721b139 commit 3df5179
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
16 changes: 10 additions & 6 deletions AlamofireObjectMapper/AlamofireObjectMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ extension DataRequest {

let JSONObject = processResponse(request: request, response: response, data: data, keyPath: keyPath)

if let JSONObject = JSONObject,
let parsedObject = (try? Mapper<T>(context: context, shouldIncludeNilValues: false).map(JSONObject: JSONObject)){
return .success(parsedObject)
if let JSONObject = JSONObject {
let mapper = Mapper<T>(context: context, shouldIncludeNilValues: false)
do {
let parsedObject = try mapper.map(JSONObject: JSONObject)
return .success(parsedObject)
} catch {}
}

let failureReason = "ObjectMapper failed to serialize response."
Expand Down Expand Up @@ -163,10 +166,11 @@ extension DataRequest {
}

if let JSONObject = processResponse(request: request, response: response, data: data, keyPath: keyPath){

if let parsedObject = try? Mapper<T>(context: context, shouldIncludeNilValues: false).mapArray(JSONObject: JSONObject){
let mapper = Mapper<T>(context: context, shouldIncludeNilValues: false)
do {
let parsedObject = try mapper.mapArray(JSONObject: JSONObject)
return .success(parsedObject)
}
} catch {}
}

let failureReason = "ObjectMapper failed to serialize response."
Expand Down
10 changes: 8 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ let package = Package(
.library(name: "AlamofireObjectMapper", targets: ["AlamofireObjectMapper"]),
],
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "4.8.2"))
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "4.8.2")),
.package(url: "https://github.com/tristanhimmelman/ObjectMapper.git", .upToNextMajor(from: "3.4.2"))
],
targets: [
.target(
name: "AlamofireObjectMapper",
dependencies: ["Alamofire"],
dependencies: ["Alamofire", "ObjectMapper"],
path: "AlamofireObjectMapper"
),
.testTarget(
name: "AlamofireObjectMapperTests",
dependencies: ["AlamofireObjectMapper"],
path: "AlamofireObjectMapperTests"
)
]
)

0 comments on commit 3df5179

Please sign in to comment.