{"id":17994690,"url":"https://github.com/rnystrom/bottlerocket","last_synced_at":"2025-03-26T02:31:07.865Z","repository":{"id":145411439,"uuid":"90307277","full_name":"rnystrom/BottleRocket","owner":"rnystrom","description":"An experimental CLI tool for generating normalized Swift models from example JSON responses.","archived":false,"fork":false,"pushed_at":"2017-05-12T21:27:55.000Z","size":2819,"stargazers_count":12,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T01:41:33.605Z","etag":null,"topics":["code-generation","json-response","swift","swift-models"],"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/rnystrom.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}},"created_at":"2017-05-04T20:36:08.000Z","updated_at":"2023-09-11T13:47:13.000Z","dependencies_parsed_at":"2023-06-03T17:15:11.926Z","dependency_job_id":null,"html_url":"https://github.com/rnystrom/BottleRocket","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rnystrom%2FBottleRocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rnystrom%2FBottleRocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rnystrom%2FBottleRocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rnystrom%2FBottleRocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rnystrom","download_url":"https://codeload.github.com/rnystrom/BottleRocket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245576528,"owners_count":20638125,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["code-generation","json-response","swift","swift-models"],"created_at":"2024-10-29T20:16:06.317Z","updated_at":"2025-03-26T02:31:07.331Z","avatar_url":"https://github.com/rnystrom.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BottleRocket\n\nAn experimental CLI tool for generating normalized Swift models from example JSON responses.\n\n## Goals\n\n- Generate Swift models that don't need any cleanup by hand\n- Allow parsing partial JSON responses into the same model\n  - Properties that don't show up in every model are optional\n- Generated Swift JSON parsing code without dependencies\n- Experiment with functional programming techniques in Swift\n\n## Installation\n\n- Download project\n- Open `BottleRocket.xcodeproj`\n- Build\n- Should be installed in `/usr/local/bin`\n\n## Example\n\nSuppose you have two different endpoints that return JSON:\n\n`http://myservice.com/api/events`\n\n```json\n{\n  \"title\": \"Birthday party\",\n  \"likes\": 12,\n  \"is_public\": true,\n  \"users\": [\n    {\n      \"name\": \"Sam\",\n      \"id\": 1\n    },\n    {\n      \"name\": \"Zoey\",\n      \"id\": 2\n    }\n  ]\n}\n```\n\n`http://myservice.com/api/user/1`\n\n```json\n{\n  \"name\": \"Sam\",\n  \"age\": 28,\n  \"id\": 1,\n  \"horoscope\": \"gemini\"\n}\n```\n\nYou can save both sample responses into two files: `events.json` and `user.json`. Then run:\n\n```shell\n$ bottlerocket gen ~/path/to/models\n```\n\nWhich then generates two different models:\n\n```swift\nfinal class Event: NSCoding {\n  let title: String\n  let likes: NSNumber\n  let is_public: Bool\n  let users: [User]\n\n  init(title: String, likes: NSNumber, is_public: Bool, users: [User]) {\n    // ...\n  }\n\n  convenience init?(json: [String: Any]) {\n    // unpack and parse models\n    // call designated init\n  }\n\n  // encode/decode\n}\n\nfinal class User: NSCoding {\n  let name: String\n  let id: NSNumber\n\n  // only shows up in api/user/1 response\n  let age: NSNumber?\n  let horoscope: String?\n\n  // init, json, coding, etc\n}\n```\n\n## Dependencies\n\n- [InflectorKit](https://github.com/mattt/InflectorKit) to convert plural keys into singular classnames\n- [SwiftCLI](https://github.com/jakeheis/SwiftCLI) because this is my first CLI app\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frnystrom%2Fbottlerocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frnystrom%2Fbottlerocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frnystrom%2Fbottlerocket/lists"}