3lvis / Networking

Swift HTTP Networking with stubbing and caching support
MIT License
1.36k stars 112 forks source link

Add support for data type and initial tests #211

Closed 3lvis closed 7 years ago

aasatt commented 7 years ago

Is init(_ data:) ever used?

3lvis commented 7 years ago

@aasatt was supposed to be used when initializing the JSONResult.

aasatt commented 7 years ago

I don't agree with this part:

if let dictionary = body as? [String: Any] {
     json = JSON(dictionary)
 } else if let array = body as? [[String: Any]] {
     json = JSON(array)
  } else if let data = body as? Data {
     json = JSON(data)
 } else {
     json = JSON.none
 }

At least it's incomplete since it will never be initialized with a Data body.

func handleJSONRequest(...) will always deserialize JSON data and func requestJSON will always initialize JSONResult with that deserialized body.

3lvis commented 7 years ago

@aasatt Hi! That was a brainfart, I think this is what you wanted: https://github.com/3lvis/Networking/pull/213