{"id":19311649,"url":"https://github.com/possen/resonancekit","last_synced_at":"2026-06-23T08:31:45.723Z","repository":{"id":66876309,"uuid":"265707338","full_name":"possen/ResonanceKit","owner":"possen","description":"ResonanceKit is a framework for async json rest frameworks. It utilizes Coroutines to allow awaiting on main thread. ","archived":false,"fork":false,"pushed_at":"2020-07-10T21:33:11.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-07T07:02:36.292Z","etag":null,"topics":["await","codable","decodable","encodable","lightweight","mock","networking","swift","swift-package-manager","swift5","testing"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/possen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-20T23:25:35.000Z","updated_at":"2020-07-10T21:33:13.000Z","dependencies_parsed_at":"2023-03-11T00:25:08.631Z","dependency_job_id":null,"html_url":"https://github.com/possen/ResonanceKit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/possen/ResonanceKit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/possen%2FResonanceKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/possen%2FResonanceKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/possen%2FResonanceKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/possen%2FResonanceKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/possen","download_url":"https://codeload.github.com/possen/ResonanceKit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/possen%2FResonanceKit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34682622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-23T02:00:07.161Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["await","codable","decodable","encodable","lightweight","mock","networking","swift","swift-package-manager","swift5","testing"],"created_at":"2024-11-10T00:29:41.179Z","updated_at":"2026-06-23T08:31:45.700Z","avatar_url":"https://github.com/possen.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ResonanceKit\nResonanceKit is a very lightweight framework, compared to something like AlamoFire, for async JSON REST requests utilizing the `Codable` protocols to \nget the model objects from the server. It is pure Swift. It utilizes Coroutines to allow awaiting on main dispatch queue or any other queue you like. \n\nIn addition to handing the decoding and encoding requests, it uses Await symantics so that you can make multiple requests as if they are sequential\nbefore returning the final result. This greatly simplifies your code and avoids callback hell. Eventually coroutine support will be built into, likely, \nSwift 6, and will be the way to make concurrent network requests in the future.\n\n## Built-in mock server for testing\nIt provides a injectable mock session that simulates talking to the real server, by putting your requests in a folder structure that mimics the folder \nstructure on the real server and returning the same `JSON` for those requests you can run tests quickly and reliably.\n\n## Other minor features:\n* An extension to `UIImageView` to allow downloading of images with an in memory `LRU` Cache. \n* A convineient way of printing out the request so you can easily paste it into `curl` for debugging requests.\n\n# How to use\nSimply import using Swift Package Manager `https://github.com/possen/ResonanceKit.git` then `import ResonanceKit` and `import SwiftCoroutines` in files\nthat need to make network requests.\n\nCreate a session with your base URL: \n\n    session = JSONSession(baseURL: \"https://MyGreatRestService.com\")\n   \nSetup your decoding strategies: \n\n    session.keyDecodingStrategy = .convertFromSnakeCase\n    \nSimilar properties exist for encoding an object to send to the request body. \n   \nFrom there just create a request object with the decodable type of the object you need. Then perform your network request where `Person` is `Decodable`:\n\n    let request = JSONRequest\u003cPeople, ErrorResponse\u003e(\n        method: .get,\n        path: \"api/1.0/people/\n        session: session\n    )\n    return try request.perform(parameters: [\"search\": filter, \"page\": String(page)]).await()\n\nThe call must be wrapped in the call to `DispatchQueue.main.startCoroutine()` at some point in your request call stack, this can be high up in your\n`NetworkController` just so long as it is in the callstack of the request. As mentioned earlier, you don't have to put it on the main queue, but \nit won't block because it utilises CoRoutines. Which are similar to coooperative multithreading. \n\n### Example Person Model Object:\n\n    struct People: Decodable {\n        var count: Int\n        let next: URL?\n        var results: [Person]\n    }\n\n    struct Person: Decodable, CustomStringConvertible, Hashable {\n\n        var description: String {\n            return name\n        }\n\n        let name: String\n        let birthYear: String\n        let eyeColor: String\n        let height: String\n        let mass: String\n        let skinColor: String\n        let homeworld: URL\n        let films: [URL]\n        let species: [URL]\n        let starships: [URL]\n        let vehicles: [URL]\n        let created: Date\n        let edited: Date\n        let url: URL\n    }\n\n## To use Testing \n\nEach file in that folder structure is a JSON\nfile which has the following structure which is an array so you can have multiple responses in the same file:\n\n* A `request` section to validate the matching of the request:\n* A `status` section to simulate the different response codes\n* A `method` section to match the type of request\n* A `response` section which is the JSON response as if it were coming back from real server\n\n### Example Mock Response put in folder Mocks/People.json:\n\n        [{\n            \"request\": {},\n            \"status\": 200,\n            \"method\": \"GET\",\n            \"response\": {\n                \"count\": 82,\n                \"next\": \"http://swapi.dev/api/people/?page=2\",\n                \"previous\": null,\n                \"results\": [\n                    {\n                        \"birth_year\": \"19BBY\",\n                        \"created\": \"2014-12-09T13:50:51.644000Z\",\n                        \"edited\": \"2014-12-20T21:17:56.891000Z\",\n                        \"eye_color\": \"blue\",\n                        \"films\": [\n                            \"http://swapi.dev/api/films/1/\",\n                            \"http://swapi.dev/api/films/2/\",\n                            \"http://swapi.dev/api/films/3/\",\n                            \"http://swapi.dev/api/films/6/\"\n                        ],\n                        \"gender\": \"male\",\n                        \"hair_color\": \"blond\",\n                        \"height\": \"172\",\n                        \"homeworld\": \"http://swapi.dev/api/planets/1/\",\n                        \"mass\": \"77\",\n                        \"name\": \"Luke Skywalker\",\n                        \"skin_color\": \"fair\",\n                        \"species\": [],\n                        \"starships\": [\n                            \"http://swapi.dev/api/starships/12/\",\n                            \"http://swapi.dev/api/starships/22/\"\n                        ],\n                        \"url\": \"http://swapi.dev/api/people/1/\",\n                        \"vehicles\": [\n                            \"http://swapi.dev/api/vehicles/14/\",\n                            \"http://swapi.dev/api/vehicles/30/\"\n                        ]\n                    },\n                    {\n                        \"birth_year\": \"112BBY\",\n                        \"created\": \"2014-12-10T15:10:51.357000Z\",\n                        \"edited\": \"2014-12-20T21:17:50.309000Z\",\n                        \"eye_color\": \"yellow\",\n                        \"films\": [\n                            \"http://swapi.dev/api/films/1/\",\n                            \"http://swapi.dev/api/films/2/\",\n                            \"http://swapi.dev/api/films/3/\",\n                            \"http://swapi.dev/api/films/4/\",\n                            \"http://swapi.dev/api/films/5/\",\n                            \"http://swapi.dev/api/films/6/\"\n                        ],\n                        \"gender\": \"n/a\",\n                        \"hair_color\": \"n/a\",\n                        \"height\": \"167\",\n                        \"homeworld\": \"http://swapi.dev/api/planets/1/\",\n                        \"mass\": \"75\",\n                        \"name\": \"C-3PO\",\n                        \"skin_color\": \"gold\",\n                        \"species\": [\n                            \"http://swapi.dev/api/species/2/\"\n                        ],\n                        \"starships\": [],\n                        \"url\": \"http://swapi.dev/api/people/2/\",\n                        \"vehicles\": []\n                    },\n\n                ]\n            }\n        }\n        ]\n\n# Dependencies\nThe dependencies are meant to keep it as lightweight as possible and as system support becomes available, I will try to eliminate these.\n* SwiftCoroutines - for coroutine support really nice package for doing await and coroutine support. \n* SwiftyBeaver - for logging requests. Uses my fork of it to allow bundling as a `Built for Distribution` flag which does not work due to a module namespace issue,\nWould use new logging announced at WWDC 2020 but that would limit the use to prerelease software. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpossen%2Fresonancekit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpossen%2Fresonancekit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpossen%2Fresonancekit/lists"}